mscorlib 2.0.0.0 4.0.0.0 System.Delegate System.Runtime.InteropServices.ComVisible(false) `` System.Void To be added.

When a managed thread is created, the method that executes on the thread is represented by a delegate or a delegate that is passed to the constructor. The thread does not begin executing until the method is called. The or delegate is invoked on the thread, and execution begins at the first line of the method represented by the delegate. In the case of the delegate, the object that is passed to the method is passed to the delegate.

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

When you create a delegate for an instance method in C++, the first parameter of the constructor is the instance variable. For a static method, the first parameter of the constructor is zero. For a static method, the delegate constructor requires only one parameter: the address of the callback method, qualified by the class name.

The delegate and the method overload make it easy to pass data to a thread procedure, but this technique is not type safe because any object can be passed to . A more robust way to pass data to a thread procedure is to put both the thread procedure and the data fields into a worker object. For more information, see Creating Threads.

Represents the method that executes on a .