Are You Using Cancellation Token The Right Way? 5 Recommended Patterns | Exploring C# and DOTNET

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 21

  • @zdxzxzdxzx6780
    @zdxzxzdxzx6780 8 місяців тому +2

    Very, very important topic. Thanks Rahul!

    • @RahulNath
      @RahulNath  8 місяців тому +1

      Glad you liked it!

  • @brycewoods9007
    @brycewoods9007 8 місяців тому

    Nice video man. That's was really interesting. Have seen cancellation tokens as an optional parameter to functions all the time but never really saw their purpose.

    • @RahulNath
      @RahulNath  8 місяців тому

      Great to see you here Bryce and glad it was helpful!

  • @ChosenHandle
    @ChosenHandle 8 місяців тому

    Really nice video on the tooic. Thank you.

    • @RahulNath
      @RahulNath  8 місяців тому

      Glad you enjoyed it!

  • @abuzeromohammed3386
    @abuzeromohammed3386 8 місяців тому

    Thank you Rahul

    • @RahulNath
      @RahulNath  8 місяців тому

      Glad you liked it Raghad.

  • @SuriyasankarP
    @SuriyasankarP 6 місяців тому

    Hi Sir..First of all it's a great video..
    I have one query...
    I have a main function and that main function has one sub function..
    Like
    Main{
    Sub{
    Inner 1{
    Inner 1.1
    }
    Inner 2{
    Inner 2.1}
    Etcc...
    }
    }
    If I cancel Sub function with cancellation token..all the respective inner function also will cancel and it save resources right??
    Or need to pass cancellation token all of the inner function for releasing the resources??
    This is my query...
    If you answer it would be better🙂🫡

  • @juniorzucareli
    @juniorzucareli 8 місяців тому

    Excellent video!

    • @RahulNath
      @RahulNath  8 місяців тому

      Thank you very much!

  • @johncerpa3782
    @johncerpa3782 8 місяців тому

    Thanks for the video

    • @RahulNath
      @RahulNath  8 місяців тому

      Glad you liked it John!!

  • @parmarjitesh1979
    @parmarjitesh1979 8 місяців тому

    Hi cancellation tokens are not working when calling api from flutter , can you help sir ?

    • @RahulNath
      @RahulNath  8 місяців тому

      Can you provide more details on how you are using it from flutter ? How are you calling cancel on an API?

    • @parmarjitesh1979
      @parmarjitesh1979 8 місяців тому

      I am calling a api endpoint for eg : localhost:5010/odata/CHECKSTOCK?PRODUCTID=123. This request is working fine but when the user checks for multiple times stocks of different product and sometimes user generates a request but cancels it mid-way than the cancellation token is not getting trigged and than iis throws error too many files open and i think some memory leak happens and application gets very low, sir googled all possible ways but couldn't figure it out. if u could throw some light than it will be helpfull
      @@RahulNath

  • @ramashankar2750
    @ramashankar2750 8 місяців тому

    Using an idempotence along with a state machine do the job.

    • @RahulNath
      @RahulNath  8 місяців тому

      Sorry didn’t understand. Idempotency is an important concept but not sure how that helps here if you are cancelling out in between a chain of process/ functions

    • @ramashankar2750
      @ramashankar2750 8 місяців тому

      @@RahulNath Implementing cancellation token on Mircroservices using Azure functions can be a challenge due to racing/multithreading, we implemented the idempotence for the key under consideration that passes through multiple states (optional) validate/ cancel/ secure/ do/ release/ undo/ queueing/ feedback/ webaudit/ tracker/... to minimise it by responding quickly an seting up state machine to cancel duringthe process of task (10-20 tasks for an Invoice) with a transaction engine (we call it DoProcess) to overcome issues in it. e.g we will hold a E-mail to a vendor for 30 minutes before change of mind by the user. towards cancellation , we learnt over decades users issues. feedback state setsup the cancellation state and engine decides its fate. We needed Speed / Robustness/Diagnostics for support/Lean.

    • @ramashankar2750
      @ramashankar2750 8 місяців тому +1

      @@RahulNath We do not process the Request immediately but log it and send a feedback to user. Now cancellation becomes easy at any stage with idenmpotence applied (do not know what will fail and get recitified). The queue is processed like 60s/70s era of batch processing replacing the procedures with microservices for maintenance of code, and we use on premise DB in India as companies do not want their data to kept on cloud.

    • @RahulNath
      @RahulNath  8 місяців тому

      @@ramashankar2750 Absolutely using messaging would help solve a lot of these issues. I did mentioning about it in my previous video on CancellationTokens and long running processes. But when you do run into scenarios like this in your API endpoints or other synchronous processing mechanisms it's good to follow these patterns with the token. Thank you for the comment and the call out here 👍