ThreadStart Delegate

ThreadStart Delegate

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft