Understanding Threading and Application Shutdown

In Chapter 2, we state that an application terminates when its main form exits. The precise and more correct statement is that an application terminates when all foreground threads have exited. If an application does not create any threads, the only foreground thread is the main thread, and it terminates when the main form is closed; hence the original statement is true for such applications. This means you must understand what foreground threads are and how to ensure thatthey are terminated before the main form closes.

Background Threads

.NET threads can be foreground or background threads. By default, every thread explicitly created is a foreground thread and every thread from the ThreadPool or ...

Get Microsoft® Mobile Development Handbook now with O’Reilly online learning.

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