-
Book Overview & Buying
-
Table Of Contents
Mastering C# Concurrency
A task represents a common asynchronous operation. This means that we don't know when it completes. Sometimes, it is clear that we do not need this task anymore. For example, if the operation takes too long to complete, or the user clicks on the Cancel button. In this case, we need to stop the task.
One of the lower-level ways to stop a thread is by calling its Abort method. Before going on, I would like to emphasize the importance of not using this.
Never ever use Thread.Abort!
Thread.Abort raises a very special exception called ThreadAbortException on a thread that is being aborted. This exception can happen at more or less any point in your program and cannot be stopped by the usual exception handling. We can write a code with catch block and the code inside this block will work, but as soon as the catch block ends, the same exception will be raised again. But—surprise—if we call the Thread.CurrentThread.ResetAbort method inside the catch block, the thread abort request...
Change the font size
Change margin width
Change background colour