Hi,
I have a class with a mthod which does a a time consuming task. I know how to start the method in a separate thread using the Threading.Thread class. What I want to do is use callback so as to have the method report its result to another method when completed. I chose to use the asynchronous Begin/End call pattern. I searched the web for sometime for a clear clean example but couldn't could you help me please.
My thoughts are:
I have a class with a mthod which does a a time consuming task. I know how to start the method in a separate thread using the Threading.Thread class. What I want to do is use callback so as to have the method report its result to another method when completed. I chose to use the asynchronous Begin/End call pattern. I searched the web for sometime for a clear clean example but couldn't could you help me please.
My thoughts are:
VB.NET:
Private Function BeginConnect(ByVal URl As String, ByVal callback As AsyncCallback, ByVal state As Object) As IAsyncResult
'Some Code
End Function
Private Function EndConnect(ByVal result As IAsyncResult)
'Some Code
' I will only call EndOperationName when I need to get a value
End Function
Private Sub OnConnect(ByVal ar As IAsyncResult)
Debug.Print("Done")
'If I need a value returned I will call EndOperationName here.
End Sub