Creating and aborting a low-priority background thread

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.

Getting ready

We will create a simple application that defines the ...

Get C# Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.