Send Message to Parent Thread

joe_pool_is

Contributor
Joined
Jan 18, 2004
Messages
507
Location
Longview, TX [USA]
I've got an application with a thread that works great except for one thing: I don't know how to get the thread to signal and pass information back to the main form.

What is the best way to do this in VB or C# 2005?
 
Depending on your needs the two easiest ways are:
1) Pass a callback function to the thread so the thread can call this method as a means of signalling the parent.

2) Declare an event the thread can raise to signal the parent.

Another possibility is if the parent thread has a message pump (normally means it is a UI thread) the background thread could use either the SendMessage or PostMessage APIs to signal the parent.

Personally I would choose either the callback or event based methods though.
 
Back
Top