Udostępnij za pośrednictwem


Thread.Join Method (Int32)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Function Join ( _
    millisecondsTimeout As Integer _
) As Boolean
[SecuritySafeCriticalAttribute]
public bool Join(
    int millisecondsTimeout
)

Parameters

  • millisecondsTimeout
    Type: System.Int32
    The number of milliseconds to wait for the thread to terminate.

Return Value

Type: System.Boolean
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.

Exceptions

Exception Condition
ArgumentOutOfRangeException

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

ThreadStateException

The thread has not been started.

Remarks

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.

Version Notes

Silverlight for Windows Phone Silverlight for Windows Phone

When a user navigates away from a Windows Phone application, the application is typically put into a dormant state. When the user returns to a dormant application, the application automatically resumes. If the application is put into a dormant state while this API is being used, the API will not complete as expected. Applications should be designed to handle this possibility. For more information about the Windows Phone execution model, see Execution Model for Windows Phone.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.