View Single Post
  #16  
Old September 9th 08, 07:29 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 1
Default Multithreading with C#

On 5 Sep, 18:19, Dorian wrote:
Is there any way to trigger an event on the main thread once the worker
thread has finished running? I am used to doing this with forms, and having a
worker thread invoke a delegate on the main form. Since we're not working
with forms, or even controls for that matter, how would I go about doing this?


Create a simple Windows Forms control to do the thread switching for
you.
It does not need be bound to a form.

In main thread:

Control threadMarshaler; // member field
//...
threadMarshaler = new Control();
IntPtr dontcare = threadMarshaler.Handle; // Force creation of
necessary message pump

In worker thread:

threadMarshaler.Invoke(...);



Ads