ThreadStart Delegate

Represents the method that executes on a Thread.

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

No code example is currently available or this language may not be supported.

When a managed thread is created, the method that executes on the thread is represented by a ThreadStart delegate or a ParameterizedThreadStart delegate that is passed to the Thread constructor. The thread does not begin executing until the Thread::Start method is called. Execution begins at the first line of the method that is represented by the ThreadStart or ParameterizedThreadStart delegate.

NoteNote:

Visual Basic and C# users can omit the ThreadStart or ParameterizedThreadStart delegate constructor when creating a thread. In Visual Basic, use the AddressOf operator when passing your method to the Thread constructor; for example, Dim t As New Thread(AddressOf ThreadProc). In C#, just specify the name of the thread procedure. The compiler selects the correct delegate constructor.

This section contains two examples. The first example shows how to use a ThreadStart delegate to execute a static method, and the second shows how to use a ThreadStart delegate to execute an instance method.

The examples display their output in a TextBlock on the UI thread. To access the TextBlock from the callback thread, the examples use the Dispatcher property to obtain a Dispatcher object for the TextBlock, and then use the Dispatcher::BeginInvoke method to make the cross-thread call.

For more information about thread creation, see Creating Threads and Passing Data at Start Time.

Example 1

The following code example shows how to use a ThreadStart delegate to execute a static method.

No code example is currently available or this language may not be supported.

Example 2

The following code example shows how to use a ThreadStart delegate to execute an instance method.

No code example is currently available or this language may not be supported.

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

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

Community Additions

ADD
Show: