Hey Group,
Hoping someone can help me out. I have some code which starts up some
asynchronous code using a delegate. The code is below. Basically my
main code (not shown) calls ServerThreadSta rt.StartServer to start the
server running asynchronously. This works fine. Shouldn't be any
problems here.
My question is how can I get my code to kill this code running
asynchronously? There is a dlgtServer.Remo ve(Delegate, Delegate)
command but there seems to be little of value in MSDN to help you
determine the two parameters.
Hope you can help,
Stewart
Friend Delegate Sub ListenForConnec tionDelegate(By Val PortNo As Int16)
Friend Class ServerThreadSta rter
Friend Shared Sub StartServer(ByV al PortNo As Int16)
Dim ar As IAsyncResult
Dim dlgtServer As New ListenForConnec tionDelegate(Ad dressOf
ServerThread.Li stenForConnecti on)
ar = dlgtServer.Begi nInvoke(PortNo, AddressOf
CallbackFromSer verThread, dlgtServer)
ar = Nothing
dlgtServer = Nothing
End Sub
Private Shared Sub CallbackFromSer verThread(ByVal ar As
IAsyncResult)
' Retrieve the delegate
Dim dlgt As ListenForConnec tionDelegate = CType(ar.AsyncS tate,
ListenForConnec tionDelegate)
' Call EndInvoke
dlgt.EndInvoke( ar)
dlgt = Nothing
End Sub
End Class
Friend Class ServerThread
Friend Shared Sub ListenForConnec tion(ByVal PortNo As Int16)
...
End Sub
End Class
Hoping someone can help me out. I have some code which starts up some
asynchronous code using a delegate. The code is below. Basically my
main code (not shown) calls ServerThreadSta rt.StartServer to start the
server running asynchronously. This works fine. Shouldn't be any
problems here.
My question is how can I get my code to kill this code running
asynchronously? There is a dlgtServer.Remo ve(Delegate, Delegate)
command but there seems to be little of value in MSDN to help you
determine the two parameters.
Hope you can help,
Stewart
Friend Delegate Sub ListenForConnec tionDelegate(By Val PortNo As Int16)
Friend Class ServerThreadSta rter
Friend Shared Sub StartServer(ByV al PortNo As Int16)
Dim ar As IAsyncResult
Dim dlgtServer As New ListenForConnec tionDelegate(Ad dressOf
ServerThread.Li stenForConnecti on)
ar = dlgtServer.Begi nInvoke(PortNo, AddressOf
CallbackFromSer verThread, dlgtServer)
ar = Nothing
dlgtServer = Nothing
End Sub
Private Shared Sub CallbackFromSer verThread(ByVal ar As
IAsyncResult)
' Retrieve the delegate
Dim dlgt As ListenForConnec tionDelegate = CType(ar.AsyncS tate,
ListenForConnec tionDelegate)
' Call EndInvoke
dlgt.EndInvoke( ar)
dlgt = Nothing
End Sub
End Class
Friend Class ServerThread
Friend Shared Sub ListenForConnec tion(ByVal PortNo As Int16)
...
End Sub
End Class
Comment