How to detect if code executes in a VCL application and needs to use Synchronize?

Hello newsgroup,

this is my current logic in a thread to check if the 
'HandleIncomingData' call needs to be synchronized:


     if System.IsConsole then
     begin
       HandleIncomingData;
     end
     else
     begin
       Synchronize(HandleIncomingData);
     end;

It works fine, but only if the console application does not open VCL 
Forms. For example, I have a GUITestRunner unit test project which also 
uses APPTYPE CONSOLE to open a console window for debug output. In this 
case, System.IsConsole is True, but the Synchronize is necessary to 
avoid application freeze.

Is there an easy and not too 'expensive' way (regarding executable size) 
to check if it is a VCL application? If I simply use a check like "if 
not Assigned(Forms.Application)", the executable size for a simple 
command line application would increase by some 100K.

Best Regards,
-- 
Michael Justin
SCJP, SCJA
betasoft - Software for Delphi™ and for the Java™ platform
http://www.mikejustin.com - http://www.betabeans.de
0
Michael
3/28/2009 8:15:37 AM
embarcadero.delphi.rtl 934 articles. 0 followers. Follow

1 Replies
381 Views

Similar Articles

[PageSpeed] 28

Michael Justin wrote:

> Hello newsgroup,
> 
> this is my current logic in a thread to check if the 
> 'HandleIncomingData' call needs to be synchronized:
> 
> 
>      if System.IsConsole then
>      begin
>        HandleIncomingData;
>      end
>      else
>      begin
>        Synchronize(HandleIncomingData);
>      end;
> 
> It works fine, but only if the console application does not open VCL 
> Forms. For example, I have a GUITestRunner unit test project which
> also uses APPTYPE CONSOLE to open a console window for debug output.
> In this case, System.IsConsole is True, but the Synchronize is
> necessary to avoid application freeze.
> 
> Is there an easy and not too 'expensive' way (regarding executable
> size) to check if it is a VCL application? If I simply use a check
> like "if not Assigned(Forms.Application)", the executable size for a
> simple command line application would increase by some 100K.
> 
> Best Regards,

You could check if the applications main thread has a window named
"TApplication", using EnumThreadWindows. The RTL contains a global
variable named MainThreadID that gives you access to that threads ID.

-- 
Peter Below (TeamB)  
Don't be a vampire (http://slash7.com/pages/vampires), 
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
0
Peter
3/28/2009 9:25:25 AM
Reply:

Similar Artilces:

How to execute server side code using VBscript bcz i need at client side.
How to  execute server side code using VBscript bcz  i need at client side.Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strSCript As String = "<script language=VBScript>Call load_LF()</script>" If (Not ClientScript.IsStartupScriptRegistered("clientScript")) ThenPage.RegisterStartupScript("clientScript", strSCript) End If End Sub here i am calling the vb script function i.e <script type="text/vbscript" language="vbscript"> sub load_LF() myclass....

Can I Execute An ASP.NET 1.1 Application's ASPX Page By Using Server.Execute From An ASP.NET 2.0 Application's ASPX Page
Hi All,Can someone help on this?I have 2 ASP.NET applications, 1 built in 1.1 and the other on 2.0In 1 of the aspx pages in my ASP.NET 2.0 application, I do Server.Execute and call another aspx page which is part of the ASP.NET 1.1 application. On doing this, I get this error: Invalid path for child request. A virtual path is expected.Is there any solution for this except for using Response.Redirect (WHICH I CANT USE). If not then can someone suggest a wayout for this:Whenever a new user signs up in my ASP.NET 2.0 application, I need to create a new user in my ASP.NET 1.1...

[D2010] Can I use Assembly code in my Delphi code?
Hello all, I am new to Delphi, and I am just installing the trial version, but I have some question. Can I use assembly code without restrictions in my Object Pascal/Delphi code? Many thanks! Greets DelphiLynx I'm not quite certain what you mean by "without restriction", but yes you can use assembly code. I don't believe how to do so is documented though. However, you can look at VCL for some examples. Search in the VCL for ASM and you should find some. A quick google search also found this: http://delphi.about.com/library/bluc/text/uc052501a.htm none no...

Web application used as desktop application. Need suggestion
Hi,  I have a project which will be deployed in a shop where they sell antique items. There is a sell like 2 to 3 items a day or less. They require barcode in the application. My question is, should I make that application as web application or desktop application?. Do you think its fesible to make it as web application (function wise)? Is there any way that I can make it exe (web application) and it installs the application, make virtual directory etc (db will be access)? exe make software name. Do we have any good web application example you have seen on the internet that are ...

Firefox crashes when your using an application and that application needs to be updated.
Name: Hrach Email: stele86athotmaildotcom Product: Firefox Summary: Firefox crashes when your using an application and that application needs to be updated. Comments: I was using http://www.merriam-webster.com/dictionary/gullible to check a word and it required Quicktime, so when it opened the sound clip played and finished, once the sound clip fnished & i got a massage saying " your quicktime needs to be updated " when that massage came firefox crashed. and when i check the reason behind it, the microsoft error reporter showed something to do with quicktime. &...

Need console application to execute a web application at specified intervals.
Hi,  I need an console application which will be scheduled to run once a day. I don't want to use windows and web services. Only thing I need to do is that at a specified time of the day, the console application will execute asp.net code in C# ( my web application ) which will update the database on certain conditions if holds good otherwise just run through the code and complete the execution.  Its very urgent for and thanks in advance for help.  Regards Raj   Hi, just create your console application and use Windows Task Scheduler to let i...

Can I use HTML code to execute a function in c# code behind
I want to ask ..if it is possible to call a function  writen inside the code behind (.cs) -c#- because I am using a grid component (AxpDataGrid component)and I want to put an HTML button inside the grid and call my function when the user clicked on it .  Eng.Osman Hamadwww.jeddah4it.com hi, yes sure you can in your html just write <%# YourFunctionInCodeBehind(Parameters) %> this will call your function also there is event handler for the DataGrids called ItemDataBound fires for every new added item, regards,Mohamed Hasan Yes, Just make the function ...

Cannot use Microsoft Excel when a Delphi application that uses automat. run [Edit]
Dear all, I built an application that connect to an Excel file using a OleObject: Excel := CreateOleObject('Excel.Application'); LCID := GetUserDefaultLCID; all works fine but I cannot use Microsoft Excel externally when my application is running. If I try to open another xls file, Excel tries to open the file in my Delphi application in read only mode. It does not even show it properly but opens a weir transparent application. I just want to be able to use Excel externally and I'd like the instance opened by my Delphi application to be independent from other Exc...

Need help with deciding to use or not to use web services in a web application
Hi all, I haven't used web services at all in my web application development and now I was asked to use web services in my web application.  I was a novice in ASP.NET since I'm just changed to ASP.NET from a Java background. I used the tutorial on MSDN to create the DAL (which is a .xsd file type) and the BLL layers and it works pretty well for what the web application suppose to be but since I was asked to add a web service layer to this, I wonder how to do it?  And I wonder if it is necessary to have an additional layer?  What is the pros and cons for adding the we...

I wrote an application and used cracked delphi 7, after i bought delphi 7
I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an application and used cracked delphi 7, I sold it, after i bought delphi 7 and recompiled application, is now my application legal or? "I embezzled some money from my employer, returned the funds, and then got it back as a bonus. Can I still be arrested?" Uhhh .... didn't you just confess to a crime? > {quote:title=Ivan Ivanov wrote:}{quote} > I wrote an appli...

Do I need to use Synchronize ?
I want to display a progress bar whilst running monte carlo simulations. Say that the user selects 60,000 scenarios to run on my machine that has a 6 core processor. I will: 1. Allocate memory to hold 60,000 results 2. Set the length of a ProgressSoFar (array of integer) variable to 6 (ie one for each processor) with each value zero 2. Start 6 threads, each one running 10,000 scenarios 3. Pass a pointer when starting each thread to positions 1, 10,001, 20,001 etc of the results table, and the relevant ProgressSoFar element 4. Update the relevant element of ProgressSoFar in each ...

Need help with coding using the SAP Business one software business object(Need urgent Help)
 I face problem with inserting order record into the Database so Anybody using the SAP business one software and inserting data from webfront and pass it to a webservice and execute the insert process using the SAP Business one business object.My coding is incomplete as i am trying to insert the headers first before i enter the lines or my product. Could anybody teach me or advice me with the syntax.I need urgent help. I am doing my Final Year polytechnic project i only left with few days to complete my project. Need urgent help. Code at coding behind page:  Private Function GetBla...

Hi friends. I need a useful websites link which gives codings for chat system using asp.net
friends... Could you send me the useful links for generating chat system Thanks in advance for ur helpG Nathan Hi Gopinath, try this one out: http://www.codeproject.com/KB/applications/AliAspNetChat.aspx Also try out this if you want Ajax with your application: http://www.dynamicajax.com/fr/AJAX_Web_Chat_ASP_NET-.htmlKarthik MuthuswamyProgrammer AnalystChennai HiPlease see these linkshttp://www.codeproject.com/KB/applications/SimpleChat.aspxhttp://aspalliance.com/1217_Building_an_AJAX_Based_Web_Chatting_Application_using_ASPNET_20 http://www.4guysfromrolla.com/webtech/03220...

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

Web resources about - How to detect if code executes in a VCL application and needs to use Synchronize? - embarcadero.delphi.rtl

synchronize on the App Store on iTunes
Get synchronize on the App Store. See screenshots and ratings, and read customer reviews.

How to synchronize metronomes - YouTube
This video shows how you can synchronize a set of oscillators (e.g., metronomes, pendulum clocks, etc) by coupling them together. At the very ...

China to synchronize trade growth, economic expansion
China to synchronize trade growth, economic expansion People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, Apr, May, Jun, Jul, ...

Jailbreak Only: CloudPaste - Synchronize Your Clipboard Between All Your Apple Devices
CloudPaste is a new jailbreak tweak and service that allows users to sync their clipboard between Apple devices, including iOS devices and Mac ...

Synchronize media players for group viewing with Syncplay
Syncplay is a free tool which syncs media players over the web, allowing a scattered group of friends to watch videos together. To get started ...

Synchronize Google Calendar With Outlook
... and delete a remote iCalendar. This open-source has added support for Google Calendars, and except for some limitations, you can now synchronize ...

Professors' proposed calendar synchronizes dates with days
Two professors at Johns Hopkins University are proposing a new, universal calendar in which each day falls on the same date every year.

Sophos Synchronizes Security With Security Heartbeat
New firewall technology and endpoint software debut to provide better visibility and control for security risk.

Force Feeding At Gitmo Will ‘Synchronize’ With Ramadan
... have yet to be charged with a crime, will continue to be force fed during Ramadan. And here’s the humane part, the force feeding will be synchronized ...

Judge Koh denies Apple's request to synchronize dissolution of existing and grant of new injunction
... Samsung's request for an expedited schedule for its dissolution request. Apart from that, she doesn't believe that Apple is entitled to synchronized ...

Resources last updated: 12/13/2015 10:50:58 AM