Namespace: System.Threading
Thread
Creates and controls a thread, sets its priority, and gets its status.
Properties (1)
bool IsBackground
Gets or sets a value indicating whether or not a thread is a background thread.
Value: true if this thread is or is to become a background thread; otherwise, false.
Methods (7)
Thread(Threading.ThreadStart)Constructor
Initializes a new instance of the Thread class.
| Parameter | Description |
|---|---|
| start | A ThreadStart delegate that represents the methods to be invoked when this thread begins executing. |
void Sleep(Int32)
Suspends the current thread for the specified number of milliseconds.
| Parameter | Description |
|---|---|
| millisecondsTimeout | The number of milliseconds for which the thread is suspended. If the value of the millisecondsTimeout argument is zero, the thread relinquishes the remainder of its time slice to any thread of equal priority that is ready to run. If there are no other threads of equal priority that are ready to run, execution of the current thread is not suspended. |
bool Yield
Causes the calling thread to yield execution to another thread that is ready to run on the current processor. The operating system selects the thread to yield to.
Returns: true if the operating system switched execution to another thread; otherwise, false.
void SpinWait(Int32)
Causes a thread to wait the number of times defined by the iterations parameter.
| Parameter | Description |
|---|---|
| iterations | A 32-bit signed integer that defines how long a thread is to wait. |
void Start
Causes the operating system to change the state of the current instance to Running.
void Join
Blocks the calling thread until the thread represented by this instance terminates, while continuing to perform standard COM and SendMessage pumping.
void SetApartmentState(Threading.ApartmentState)
Sets the apartment state of a thread before it is started.
| Parameter | Description |
|---|---|
| state | The new apartment state. |