What Else Can Be Done to a Thread?

You can interrupt a thread, suspend a thread, resume a thread, and abort a thread. Figure 11.3 shows an application running whereby all these operations are interacting. The full source to this application is available in the ThreadAbort directory.

Figure 11.3. Thread manipulation.

Only one button is enabled at startup: the Start button. By pressing this button, a Thread is started. When the Thread is started, it waits for the ManualResetEvent to be signaled. One of the first things that you might try is to start it again. Notice that the Start button is not disabled after a Thread has started. If the Thread

Get .NET Common Language Runtime Unleashed 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.