Search⌘ K

Parameterized Methods

Explore how to use the ParameterizedThreadStart delegate to run methods with parameters on threads in C#. Learn to pass single and multiple parameters safely by using objects, arrays, or custom classes for effective multithreading and asynchronous programming.

The ParameterizedThreadStart delegate

Running a parameterless method on a thread is achieved by passing an instance of the ThreadStart delegate to a Thread constructor. What if we need to pass some parameters to the thread? The ParameterizedThreadStart delegate is used for this purpose:

public Thread(ParameterizedThreadStart start)
{
}

The ParameterizedThreadStart ...