How to cancel a Task in await?
Read up on Cancellation (which was introduced in .NET 4.0 and is largely unchanged since then) and the Task-Based Asynchronous Pattern, which provides guidelines on how to use CancellationToken with async methods. To summarize, you pass a CancellationToken into each method that supports cancellation, and that method must check it periodically. private async Task TryTask() … Read more