How to communicate between threads

  • Thread starter Thread starter Christian Havel
  • Start date Start date
C

Christian Havel

Hi,

I have one thread thats method is called. When the method is called another
thread should be notified. How do I do this?

Christian
 
Depends on the scenario... you could use something like a
ManualResetEvent/AutoResetEvent; you could use a Monitor (Pulse etc). If
the other thread is a UI thread you could use an event (or a delegate as
a callback), and then have the UI jump to the UI-thread via
Control.Invoke/Control.BeginInvoke (or the WPF equivalent); or
SynchronizationContext...

It really depends what the other thread is doing... in particular, you
don't want the first thread to *just* spin up the second thread and then
wait for it to finish - you could just as easily do everything on the
first thread.

Marc
 

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

Back
Top