Re: Form freezing form

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Ioannis Vranos" <ivr@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:OoZNByhYFHA.2756@xxxxxxxxxxxxxxxxxxxxxxx
> Tamas Demjen wrote:
>
>> When you update the form from the thread, are you taking care of the
>> synchronization? Only the main thread is allowed to modify the GUI, you
>> can't do it directly from the thread, you have to do the update via
>> Control::Invoke.
>
>
> Do you mean I should create a delegate for this? However my question is
> this, as far as I understand, before the Application::DoEvents() use, the
> form got "frozen" because of the frequency of the updates. Why this will
> not happen when Invoke() is used?

Because your actual work is done on another thread and as such doesn't block
the thread's message pump, the only thing what's done on the UI thread is
updating the UI (paint, handle mouse moves/clicks, KB input etc...).
Note that Control.Invoke and (preferable) BeginInvoke simply post a message
(that basically contains the address of the function to execute) to the
message queue, such that the function is executed on the UI thread (well the
thread owning the Control).

Willy.


.



Relevant Pages

  • Re: OS Threads behavior
    ... > might run at higher priorities than your threads. ... >>I care about it, since I need it, "This answer is so famelies in Microsoft ... >> heavy tools in this language, the language does not support Hardware ... it's the OS the one who decide which thread to execute. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SSIS Performace/Design
    ... If you do not care about the order of the data being loaded then I would be tempted on a multi proc box to divide my source data into ranges. ... Now in either a single Data Flow Task with CPU Count - 1 Pipelines or CPU Count - 1 Data flow tasks with 1 pipeline in each you move that data in parallel. ... is copied I then execute some execute sql task on individual tables. ...
    (microsoft.public.sqlserver.dts)
  • Re: File browser
    ... Any time you get your code to be called on the EDT, you are now in control. ... So it should be simple enough to write code that intentionally causes something to be called on the EDT, at which point one can take advantage of that control to ensure a synchronization error. ... Unfortunately, because it's specifically using invokeLaterto get code to execute on the EDT, it's not a demonstration of the problem I'm asking about. ... Before any components are shown, user actions won't affect when things are executed on the EDT. So, what of those "factors external to your application"? ...
    (comp.lang.java.programmer)
  • Re: Synchronization Question
    ... That sort of reordering is exactly what "volatile" and other synchronization techniques resolve. ... order of execution within the thread isn't a guarantee of order of visibility of the results outside the thread. ... He seems to care that his code will see _some_ written value, but not necessarily about the order of writes. ... Thus the suggestions so far that he simply do a "join" or similar to create a synchronization barrier that will force the "happens-before/after" relationship, rather than attempt any synchronization during the processing itself. ...
    (comp.lang.java.programmer)
  • Re: OS Threads behavior
    ... Unless you have a quad CPU machine, ... >I care about it, since I need it, "This answer is so famelies in Microsoft ... > heavy tools in this language, the language does not support Hardware ... it's the OS the one who decide which thread to execute. ...
    (microsoft.public.dotnet.languages.csharp)