System.Threading.Thread.Join Method

Blocks the calling thread until a thread terminates or the specified time elapses, while continuing to perform standard COM and SendMessage pumping.

Syntax

public bool Join (TimeSpan timeout)

Parameters

timeout
A TimeSpan set to the amount of time to wait for the thread to terminate.

Returns

true if the thread terminated; false if the thread has not terminated after the amount of time specified by the timeout parameter has elapsed.

Exceptions

TypeReason
ArgumentOutOfRangeExceptionThe value of timeout is negative and is not equal to Timeout.Infinite milliseconds, or is greater than int.MaxValue milliseconds.
System.Threading.ThreadStateExceptionThe caller attempted to join a thread that is in the ThreadState.Unstarted state.

Remarks

If Timeout.Infinite is specified for timeout, this method behaves identically to the Thread.Join method overload, except for the return value.

If the thread has already terminated when erload:System.Threading.Thread.Join is called, the method returns immediately.

This method changes the state of the current thread to include ThreadState.WaitSleepJoin. You cannot invoke Join on a thread that is in the ThreadState.Unstarted state.

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0