Thread Constructor (ThreadStart^)
.NET Framework (current version)
Initializes a new instance of the Thread class.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- start
-
Type:
System.Threading::ThreadStart^
A ThreadStart delegate that represents the methods to be invoked when this thread begins executing.
| Exception | Condition |
|---|---|
| ArgumentNullException | The start parameter is null. |
A thread does not begin executing when it is created. To schedule the thread for execution, call the Start method.
Note |
|---|
Visual Basic users can omit the ThreadStart constructor when creating a thread. Use the AddressOf operator when passing your method for example Dim t As New Thread(AddressOf ThreadProc). Visual Basic automatically calls the ThreadStart constructor. |
The following code example shows how to create a thread that executes a static method.
using namespace System; using namespace System::Threading; ref class Work { private: Work(){} public: static void DoWork(){} }; int main() { Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Work::DoWork ) ); newThread->Start(); }
The following code example shows how to create a thread that executes an instance method.
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Show:
