Search⌘ K

Working with Threads

Explore thread creation in C#, including using ThreadStart and ParameterizedThreadStart delegates. Understand safe methods to pass arguments and retrieve results from threads for concurrency management.

Threads

In one of the previous sections, we defined thread as the smallest unit of execution. In this section, we'll look at all the ways to create threads.

Specifying ThreadStart

The class ThreadStart represents the method that a thread will execute. Essentially, ThreadStart is a delegate. A delegate is nothing but a reference to a method. Delegates are similar to function pointers that exist in C and C++. All delegates implicitly inherit from the System.Delegate class.

We can specify an instance or a static method when instantiating a ...