This documentation is archived and is not being maintained.

Creating Threads

The .NET Framework allows you to create multithreaded applications quickly and easily by providing an object-oriented threading model. Creating a new thread is as easy as declaring it and supplying it with a delegate to the method where the thread is to start. When you are ready to begin execution on the thread, call the Thread.Start Method. There are special considerations involved when working with multiple threads of execution. For an overview of techniques involved in working with multiple threads, see Thread-Safe Components.

To create a new thread of execution

  1. Declare the thread.
    ' Visual Basic
    Dim myThread as System.Threading.Thread
    // C#
    System.Threading.Thread myThread;
  2. Instantiate the thread with the appropriate delegate for the starting point of the thread. Use the AddressOf operator to create the delegate in Visual Basic, or create a new ThreadStart object in C#.
    ' Visual Basic
    myThread = New System.Threading.Thread(AddressOf myStartingMethod)
    // C#
    myThread = new System.Threading.Thread(new 
  3. When ready, call the Thread.Start method to start the thread.
    ' Visual Basic
    // C#

See Also

Thread-Safe Components | Coordinating Multiple Threads of Execution | Multithreading in Components