No video

🔥 How to use CancellationToken in ASP.NET Core WebApi

  Рет қаралды 8,157

Saeed Esmaeelinejad

Saeed Esmaeelinejad

Күн бұрын

Пікірлер: 37
@TellaTrix
@TellaTrix 4 ай бұрын
Wow, Amazing content Saeed. I know what the main problem in my organization project. I have poorly managed all resources. I am going to fix them soon.
@sa-es-ir
@sa-es-ir 4 ай бұрын
Best of luck with new fixes, hope it will boost your app, Thanks
@aaa-pt7lm
@aaa-pt7lm 10 ай бұрын
Really good work and valueable share 👍👍
@sa-es-ir
@sa-es-ir 10 ай бұрын
Glad you like it
@rahulsinghishere
@rahulsinghishere 8 ай бұрын
Very Informative, Thanks
@sa-es-ir
@sa-es-ir 8 ай бұрын
Glad you like it 🌷
@philskay8724
@philskay8724 19 күн бұрын
A lot of knowledge here, Thanks
@sa-es-ir
@sa-es-ir 17 күн бұрын
My pleasure and please help me to share it with your network.
@fabrizziocht
@fabrizziocht 11 ай бұрын
Great explanation, thank you!
@sa-es-ir
@sa-es-ir 11 ай бұрын
Glad you like it
@saddamhossaindotnet
@saddamhossaindotnet 11 ай бұрын
I am very excited man! Already Subscribed. :)
@sa-es-ir
@sa-es-ir 11 ай бұрын
Awesome! Thank you!
@Arasaik
@Arasaik 10 ай бұрын
Hey Saeed, This video was so helpful. Keep going. Please create a video on how to make an asynchronous HttpRequest.
@sa-es-ir
@sa-es-ir 10 ай бұрын
Thanks for the feedback, sure I'll do
@rezabayat9222
@rezabayat9222 11 ай бұрын
great Saeed. there is one missing part: when to use CancellationToken.None. sometimes we have multiple operations, in which all of them accept cancellationToken; but after specific operation we should not cancel the process. for example: var transfer = service1.GetTransfer(cancellationToken); service2.DoTransfer(transfer, someArgs, cancellationToken); service3.TransferApplied(transer, CancellationToken.None); if we pass the cancellationToken to the third service, if the request is cancelled, we would have an inconsistent state. sometimes we should pass CancellationToken.None, if we want that our code continues running, even if the request is cancelled by the user , timeout, etc.
@sa-es-ir
@sa-es-ir 11 ай бұрын
Great input Reza and totally agree, actually it depends on sepecfic requirements but in such cases for keeping task running maybe we don't need to use CancellationToken at all.
@rezabayat9222
@rezabayat9222 10 ай бұрын
You are completely right. But there ist one problem: when you do not pass the cancellation token parameter, other programmers may see warnings or later on want to improve the code and add the cancellation token. So to avoid such cases, we can pass the None, to say that it was a known issue.
@rezakamrani4440
@rezakamrani4440 11 ай бұрын
Just Keep Going!
@sa-es-ir
@sa-es-ir 11 ай бұрын
Thanks Kamrani jun❤️
@smc_onetwo
@smc_onetwo 5 ай бұрын
should we be using the cancellation token on POST and UPDATE requests?
@sa-es-ir
@sa-es-ir 5 ай бұрын
Yes everywhere! For Post or update requests, its more important to use CancellationToken because in any exceptions those changes can be rolled back.
@thecodeman_
@thecodeman_ 11 ай бұрын
Keep going!
@sa-es-ir
@sa-es-ir 11 ай бұрын
Thank you Stefan, I'll do❤
@ishfaqbabar1192
@ishfaqbabar1192 8 ай бұрын
Will it work only on webServer (Kestrel) or it will also work on Out-of-process hosting (IIS) or In-process hosting (IIS)?
@sa-es-ir
@sa-es-ir 8 ай бұрын
Works with all webservers including IIS as well.
@JohnSmith-yr7ih
@JohnSmith-yr7ih 11 ай бұрын
Please zoom your IDE, it is difficult to watch with phone, and please provide code, direct link of project for every tutorial.
@sa-es-ir
@sa-es-ir 11 ай бұрын
Appreciate for the feedback, very true, I try to keep them in mind for the next video
@muttBunch
@muttBunch 8 ай бұрын
Saeed, this is awesome. Thank you. Is there anyway to send a cancellation via another endpoint to cancel? I made a live log monitor which runs a while loop looking for !token.IsCancellationRequested, but when it’s running, I’d like to send like a stop parameter to it from another action result. It’s cool that we have Swagger, Postman, etc but in a real world app, obviously the user won’t be interfacing with either of those. Thanks.
@sa-es-ir
@sa-es-ir 8 ай бұрын
Happy you like it. About the question, the CancellationToken in automatically createe by webServer (Kestrel) so doesn't make sense to CancellationToken to another request and won't work but if the purpose is only cancelling the second request you can disconnect or abort that request (so the other side will be cancelled)
@heribertodejesusdejesus8316
@heribertodejesusdejesus8316 11 ай бұрын
Muchas gracias por la aportación, me has dado mejor visión del uso adecuado del CancellationToken, será interesante ponerlo en práctica. Por otro lado, en el video muestras el ejemplo de la capa de repositorio por EF, sin embargo, si el escenario fuera que para esta capa la comunicación es por StoreProcedures donde para "delete, insert o update " manejan sus propias transacciones, ¿sería recomendable el uso del CancellationToken?
@sa-es-ir
@sa-es-ir 11 ай бұрын
It's recommended to use CancellationToken if the method accept it, usually all methods that has "Async" postfix they accept it. In case of stored procedure it's the same and CancellationToken should used as well as it will be cancelled on database
@heribertodejesusdejesus8316
@heribertodejesusdejesus8316 11 ай бұрын
Agradezco tu tiempo y pronta respuesta, ya me suscribí a tu canal, excelente día.
@shreypaidhungat6280
@shreypaidhungat6280 11 ай бұрын
Subscribed :)
@sa-es-ir
@sa-es-ir 11 ай бұрын
Thank you🌷
@cleitoncarlospereira2006
@cleitoncarlospereira2006 10 ай бұрын
Hey Saeed, This video was so helpful. Keep going. Please create a video on how to make an asynchronous HttpRequest.
@sa-es-ir
@sa-es-ir 10 ай бұрын
Very glad you like it, Sure it's on my list, stay tuned :)
5 Rules For DTOs
17:56
Ardalis
Рет қаралды 40 М.
💥 gRPC on .NET: How to use gRPC in ASP.NET Core Api
25:05
Saeed Esmaeelinejad
Рет қаралды 3,1 М.
Мы сделали гигантские сухарики!  #большаяеда
00:44
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 14 МЛН
Вы чего бл….🤣🤣🙏🏽🙏🏽🙏🏽
00:18
are we seriously STILL talking about this?
10:00
Low Level Learning
Рет қаралды 10 М.
NVIDIA Needs to STOP - RTX 3050 & Misleading Branding
11:35
Linus Tech Tips
Рет қаралды 1,2 МЛН
We NEED To Talk About The War Within
24:51
Bellular Warcraft
Рет қаралды 218 М.
The RIGHT Way To Use HttpClient In .NET
11:46
Milan Jovanović
Рет қаралды 56 М.
ASP.NET Core Authentication Simplified | .NET Conf 2023
24:47
Clean ASP.NET Core API using MediatR and CQRS | Setup
22:39
Nick Chapsas
Рет қаралды 321 М.
Мы сделали гигантские сухарики!  #большаяеда
00:44