Hey 👋 Imagine having a long-running request triggered by a user on your server. But, the user is no longer interested in the result and has navigated away from the page.
However, the server is still processing that request and utilizing resources until you come along and implement Cancellation Tokens in the application code.
.NET uses Cancellation Token for cooperative cancellation of asynchronous or long-running synchronous operations.
So let’s learn more about Cancellation Token and save some of that server compute time.
I will show you the problem of unnecessarily spending server resources on no longer required processes and how to solve them using Cancellation Tokens.
We will see an example of using Cancellation tokens in a console application, in a long-running HTTP API Endpoint, and when making external calls to API Endpoints. I will use Amazon S3 to show how you can use Cancellation Tokens to cancel from uploading large documents when they are no longer required.
Thank you to AWS for sponsoring this video.
🔗 Blog - https://www.rahulpnath.com/blog/cance...
🔗 Code - https://github.com/rahulpnath/youtube...
00:00 Introduction
00:44 The Problem
03:22 What is Cancellation Token
04:48 Cancellation Token Demo
08:12 Passing Cancellation Tokens
10:09 Listening to Cancellation Requests
10:32 Cancellation Token In API
13:30 Cancellation Token and HTTP API Calls
13:54 AWS S3 Storage
18:05 Should you always Cancel?
Additional Watching
📹C# Series - https://bit.ly/mycsharp
📹 ASP Series - https://bit.ly/asp-net-core-series
📹Azure Series - https://bit.ly/azure-series
📹AWS Series - https://bit.ly/aws-net-series
📹RabbitMQ Series - https://bit.ly/rabbitmq-net-series
Come say hi! ✋
🎙️Uses - https://www.rahulpnath.com/uses
🌍Blog - https://www.rahulpnath.com/
✉ Subscribe to my Newsletter - https://www.rahulpnath.com/subscribe
🐦Twitter - / rahulpnath
📸Instagram - / rahulpnath
#dotnet #csharp
Watch video Cancellation Token in .NET | Exploring C# and DOTNET online without registration, duration hours minute second in high quality. This video was added by user Rahul Nath 14 March 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 6,25 once and liked it 30 people.