O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Perform an Asynchronous Task with the Thread Class

Problem

You want to execute a task on another thread and be able to control that thread’s priority, state, and so on.

Solution

Create a new System.Threading.Thread object that references the code you want to execute asynchronously, and use the Start method.

Discussion

The Thread object allows you to write multithreaded code with a finer degree of control than that provided by asynchronous delegates. As with delegates, the Thread class can only point to a single method. However, unlike delegates, the Thread class can only execute a method that takes no parameters and has no return value. (In other words, it must match the signature of the System.Threading.ThreadStart delegate.) If you need to send data ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required