I thoroughly enjoyed your explanation using the two charts. In the video, you didn't mention or conclude on what happened to R6 when the request was completed by the database. Secondly, what is the usefulness of the CancelationToken? How do I know when to use one?
Not sure I get the point on R6. It would follow the same path as all the others before it, but maybe you can detail more what's your doubt?
As for cancellation tokens, ideally almost all async methods should get them.
Two possible scenarios where they are useful are:
When the result is no longer required
When you, for some reason want to abort the operation
An example of 1, is for example if you get a request from the browser, but the user goes away before it is completed, the connection being closed triggers the token cancellation, so the application can cancel what it's doing, as it'll be no longer useful. You can see an example of this in action in this post.
As for 2, imagine you have an application running in the background doing things, but then it gets signaled to stop (e.g. stop a Windows service). This signal can trigger a cancellation token and the application can abort what it's doing, so it can stop gracefully.
Yes, your explanation above makes more sense to me now. Now I know where and when to use the CancelationToken. I will come here for more questions when I move to other episodes in the series. Thank you once again for the knowledge shared and time.
I thoroughly enjoyed your explanation using the two charts. In the video, you didn't mention or conclude on what happened to R6 when the request was completed by the database. Secondly, what is the usefulness of the CancelationToken? How do I know when to use one?
Not sure I get the point on R6. It would follow the same path as all the others before it, but maybe you can detail more what's your doubt?
As for cancellation tokens, ideally almost all async methods should get them.
Two possible scenarios where they are useful are:
An example of 1, is for example if you get a request from the browser, but the user goes away before it is completed, the connection being closed triggers the token cancellation, so the application can cancel what it's doing, as it'll be no longer useful. You can see an example of this in action in this post.
As for 2, imagine you have an application running in the background doing things, but then it gets signaled to stop (e.g. stop a Windows service). This signal can trigger a cancellation token and the application can abort what it's doing, so it can stop gracefully.
Hope this makes sense!
Yes, your explanation above makes more sense to me now. Now I know where and when to use the CancelationToken. I will come here for more questions when I move to other episodes in the series. Thank you once again for the knowledge shared and time.
Great!