Cancellation Tokens and Timeouts
See original GitHub issueHi. May be will be good if you add CancellationTokenSource or just timeout for read\write operation. Something like this:
//One sec timeout by default
public int Timeout { get; set; } = 1000;
…
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(Timeout);
await _ReadFileStream.ReadAsync(bytes, 0, bytes.Length, cancellationTokenSource.Token);
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (17 by maintainers)
Top Results From Across the Web
Using CancellationToken for timeout in Task.Run does not ...
Run action is delayed because the ThreadPool is saturated, the cancellation of the token has immediate effect because it is callback-based. The ...
Read more >Cancel async tasks after a period of time
You can cancel an asynchronous operation after a period of time by using the CancellationTokenSource.CancelAfter method if you don't want to ...
Read more >Adding a default timeout to CancellationToken parameters in ...
We can merge multiple cancellation tokens into one with CancellationTokenSource.CreateLinkedTokenSource method. Here we create a timeout token, ...
Read more >Patterns & Practices for efficiently handling C# async/await ...
CancellationTokenSource has a method called CancelAfter that fires a cancel after a certain period of time, so using this method to pass a ......
Read more >Cancellation, Part 2: Requesting Cancellation
The solution is to have a timer that requests cancellation when it expires. This is actually common enough that CancellationTokenSource has ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@datoml check out this branch
https://github.com/MelbourneDeveloper/Device.Net/tree/%232-CancellationTokens?files=1
Getting closer
@datoml @skykharkov @fengqiangboy @fxjoos @mxjones
The library now supports cancellation tokens in the develop branch. It is mostly untested so I expect there to be issues. I will test when after work hours at some point soon.