A word of caution. This only cancels the await, it does not cancel the running task. Any additional code inside the awaited task will continue to execute.
Instead, you should add and pass a cancellation token to the awaited method so that the task itself is also cancelled.
That is, Task.Delay (and almost all other awaitable methods) accept(s) a cancellation token to cancel the delay before the time out expires.
thanks bro :) Very important point you have mentioned
I have updated the post to be more clear about the IO bound operations.
good examples will be web requests or waiting on TcpClient stream and ...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A word of caution. This only cancels the await, it does not cancel the running task. Any additional code inside the awaited task will continue to execute.
Instead, you should add and pass a cancellation token to the awaited method so that the task itself is also cancelled.
That is, Task.Delay (and almost all other awaitable methods) accept(s) a cancellation token to cancel the delay before the time out expires.
thanks bro :) Very important point you have mentioned
I have updated the post to be more clear about the IO bound operations.
good examples will be web requests or waiting on TcpClient stream and ...