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 ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.