Groups | Blog | Home
all groups > vb.net > february 2007 >

vb.net : .NET EVents & Threading


Tom Shelton
2/21/2007 1:48:09 PM
[quoted text, click to view]


Or run the delegate asycronously using BeginInvoke - in that case, the
method will be called on a thread from the thread pool.

--
Tom Shelton
Spam Catcher
2/21/2007 9:18:16 PM
Hi all


When .NET fires and event, does the event handler execute under a new
thread, or does it execute under the primary application thread?

Basically if I have events firing, do the event handlers themselves need to
spawn need threads, or can I safely assume the event handler is already
running under a new thread?

Tom Shelton
2/21/2007 9:33:48 PM
[quoted text, click to view]

Yes - you should call endinvoke.

--
Spam Catcher
2/21/2007 9:43:22 PM
"Armin Zingler" <az.nospam@freenet.de> wrote in
news:uiUXtBgVHHA.4720@TK2MSFTNGP04.phx.gbl:

[quoted text, click to view]

Armin Zingler
2/21/2007 10:36:48 PM
"Spam Catcher" <spamhoneypot@rogers.com> schrieb
[quoted text, click to view]

The event handler runs in the same thread as the code that raises the event.
No thread is created. The event handler is just a function called.

[quoted text, click to view]

If you want to run something in a new thread each time the event handler is
called, you must start the thread on you own.


Armin
Spam Catcher
2/21/2007 11:33:06 PM
"Tom Shelton" <tom_shelton@comcast.net> wrote in
news:1172094489.837789.178250@q2g2000cwa.googlegroups.com:

[quoted text, click to view]

If I do so, I'll have to call EndInvoke correct?

I'm using Threadpool.QueueUserWorkItem to process each call in it's own
AddThis Social Bookmark Button