Send a message to a thread

  • Thread starter Thread starter S Shulman
  • Start date Start date
S

S Shulman

Hi

Is there any method to send a message to a running thread so the thread will
perform a specific function before the program suspends it?

Thank you,
Shmuel Shulman
 
Shmuel,

Yes. But, the thread must be implemented specifically for that type of
behavior. To create your own thread that does this you need to have it
run an infinite loop that waits for an object to appear in a queue.
When an object appears the thread wakes up and processes that object
accordingly. Other threads have access to the queue so that they can
enqueue objects at any time.

UI threads behave this way because they run a windows message pump.
Other threads can instruct the UI thread to run some function by using
Control.Invoke. Invoke takes a delegate as a parameter and posts a
message to the UI thread's message queue instructing it to execute the
specified delegate.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Terminating a thread 4
Threads 2
Invoke Method 11
String Methods 3
Click in VB the Combobox 3
[email protected] 1
Tick a checkbox 1
MenuItem35.PerformClick() 2

Back
Top