If you need the ability you should use a WaitHandle, such as AutoResetEvent
or ManualResetEvent.
Then instead of using Threading.Thread.Sleep you would use
Threading.WaitHandle.WaitOne with a timeout value. The other thread can use
*ResetEvent.Set to cause the first thread to wake up. With the timeout on
WaitOne the first thread will automatically wake up if another thread does
not call Set.
Dim event As New AutoResetEvent
Public Sub Tread1()
If event.WaitOne(2000, False) Then
' event.Set was called
Else
' event timed out
End if
End Sub
Public Sub Thread2()
event.Set() ' wake up thread1
End Sub
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.