-
Book Overview & Buying
-
Table Of Contents
C# Programming Cookbook
By :
The reason we want to have a look at a background thread specifically is because by default, all threads created by the main app thread or Thread class constructor are foreground threads. So, what exactly separates a foreground thread from a background thread? Well, background threads are identical to foreground threads with the exception that if all foreground threads are terminated, the background threads are stopped too. This is useful if you have a process in your application that must not stop the application from terminating. In other words, while your application is running, the background thread must continue to run.
We will create a simple application that defines the thread created as a background thread. It will then suspend, resume, and abort the thread.
Create a new class library by right-clicking on your solution and selecting Add and then New Project from the context menu:

From the Add New Project...