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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With