Use a TimeSpan value with the Join method.
Imports System
Imports System.Threading
Public Class Test
Shared waitTime As New TimeSpan(0, 0, 1)
<MTAThread> _
Shared Sub Main()
Dim newThread As New Thread(AddressOf Work)
newThread.Start()
If newThread.Join(TimeSpan.op_Addition(waitTime, waitTime)) Then
Console.WriteLine("New thread terminated.")
Else
Console.WriteLine("Join timed out.")
End If
End Sub
Shared Sub Work()
Thread.Sleep(waitTime)
End Sub
End Class
Related examples in the same category