![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
From the looks of what you are doing you would be better off using the Thread class to spawn your worker thread. By using a delegate's |
|
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 ServerThreadStart.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.Remove(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 ListenForConnectionDelegate(ByVal PortNo As Int16) Friend Class ServerThreadStarter Friend Shared Sub StartServer(ByVal PortNo As Int16) Dim ar As IAsyncResult Dim dlgtServer As New ListenForConnectionDelegate(AddressOf ServerThread.ListenForConnection) ar = dlgtServer.BeginInvoke(PortNo, AddressOf CallbackFromServerThread, dlgtServer) ar = Nothing dlgtServer = Nothing End Sub Private Shared Sub CallbackFromServerThread(ByVal ar As IAsyncResult) ' Retrieve the delegate Dim dlgt As ListenForConnectionDelegate = CType(ar.AsyncState, ListenForConnectionDelegate) ' Call EndInvoke dlgt.EndInvoke(ar) dlgt = Nothing End Sub End Class Friend Class ServerThread Friend Shared Sub ListenForConnection(ByVal PortNo As Int16) ... End Sub End Class |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
thrd.Abort() |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |