Given the following code
Public Shared Sub DoAsyncAction()
Using asmxProxy As New MyAsmxServiceProxy()
AddHandler asmxProxy.WebFunctionCompleted, AddressOf WebFunctionAsync_Completed
// Make the Async ASMX Webservice Call
asmxProxy.WebFunctionAsync()
// RemoveHandler asmxProxy.WebFunctionCompleted, AddressOf WebFunctionAsync_Completed
End Using
End Sub
Private Shared Sub WebFunctionAsync_Completed(ByVal sender As Object, ByVal e As MyAsmxServiceProxy.WebFunctionCompletedEventArgs)
// Do Stuff
End Sub
I was wondering how the event handler is maintained here. So, let say the WebFunctionAsync() internally takes ~30 seconds to complete. When that time is up, it will fire the WebFunctionCompleted event, but will my handler (WebFunctionAsync_Completed) still get hit even thought the webClient has been disposed and gone out of scope?
If the question to the last answer is Yes, what if I commented in the RemoveHandler line. Would it then?
I guess what I'm trying to find out is, at the time the async function is called, are the registered event handlers "cached" (so to speak) along with the call, so that no matter what happens to the ASMX proxy object or even if the handlers are removed, the registered event handlers at the time the call will still be hit when the events fire?
Maybe this is really obvious, but for some reason I can't seem to logically come to a conclusion on this, and I didn't find any answers in the few places I looked on MSDN.