6 get to know the thread pool (II)

I'm sorry you care more multi-threaded column for so long, this article we continue to talk about the knowledge of the thread pool, which will involve the following knowledge:

  1. Cancel the asynchronous operation
  2. Event handler and wait for a timeout
  3. Timer
  4. BackgroundWorker

Zero, cancel asynchronous operation

This section will introduce two classes CancellationTokenSource and CancellationToken. These two classes are being introduced in .NET 4.0, so if we need to use these two categories must be used in .NET 4.0 and above, the current standard asynchronous operation is canceled. Here we cook through cooking, cancel the order halfway example of a look at these two classes specifically how to use.

using System.Threading;
using static System.Console;
using static System.Threading.Thread;

namespace NoSix

Guess you like

Origin blog.csdn.net/gangzhucoll/article/details/103951352