Export (0) Print
Expand All

Thread.Join Method (Int32)

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

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)

public bool Join (
	int millisecondsTimeout
)
public boolean Join (
	int millisecondsTimeout
)
public function Join (
	millisecondsTimeout : int
) : boolean

Parameters

millisecondsTimeout

The number of milliseconds to wait for the thread to terminate.

Return Value

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

Exception typeCondition

ArgumentOutOfRangeException

The value of millisecondsTimeout is negative and is not equal to Timeout.Infinite in milliseconds.

ThreadStateException

The thread has not been started.

NoteNote

The HostProtectionAttribute attribute applied to this method has the following Resources property value: Synchronization | ExternalThreading. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

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

If the thread has already terminated when Join is called, the method returns immediately.

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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft