O'Reilly logo

C++ Multithreading Cookbook by Milos Ljumovic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Interrupting, aborting, and safe canceling the thread execution

Some tasks require ways to forcibly interrupt the execution of the thread. In our previous examples, we've used the Task and BackgroundWorker objects due to their background operations and the ability to be forcibly closed on exiting the application. Now, let's explain the .NET features that target normal thread interruption and safe cancelation. Each blocking method will block the thread forever if some unblocking condition is never met or the timeout is not set. However, sometimes, you need to cancel thread execution and maybe continue the execution of the application without allowing the thread to continue. In other situations, you need to cancel the thread, for example, to receive ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required