In VB .NET, when you call RaiseEvent X(), is the function that handles the event X processed asynchronously or synchronously. I was under the impression that RaiseEvent and the processing of the event were Synchronous unless created explictly on another thread. I've been told otherwise though.
+2
A:
Events are raised synchronously by default. Since MulticastDelegates
are designed to support asynchronous invocation it is possible to invoke the delegates in an event's invocation list asynchronously but this is not the default behavior.
Andrew Hare
2009-06-16 00:56:17
A:
I just did some testing also...
Public Sub MyHandler() Handles Complete
MsgBox("My Handler - Beginning 5 second sleep")
Threading.Thread.Sleep(5000)
MsgBox("My Handler - Awoken")
End Sub
Public Sub SomeFunction()
MsgBox("Some function - Raising Event")
RaiseEvent Complete()
MsgBox("Some function - After Event")
End Sub
Output:
Some function - Raising Event
My Handler - Beginning 5 second sleep
My Handler - Awoken
Some function - After Event
Josh Smeaton
2009-06-16 01:11:23