events and thread

G

Guest

Hi,
Does anyone know if raising an event spawns threads for each method that
handles the event, or does it just call each of the methods in order?
If it calls the handlers in order, and waits for each to return, can someone
suggest a good paradigm to just spawn a bunch of threads, one for each event
handler?
Thanks,
Yuri
 
M

Mattias Sjögren

Does anyone know if raising an event spawns threads for each method that
handles the event, or does it just call each of the methods in order?

The latter, no threads are created.

If it calls the handlers in order, and waits for each to return, can someone
suggest a good paradigm to just spawn a bunch of threads, one for each event
handler?

You can use Delegate.GetInvocationList to get each event handler
delegate. You may want to consider using the thread pool rather than
creating the threads explicitly.


Mattias
 

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

Top