question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cancellation Tokens and Timeouts

See original GitHub issue

Hi. 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:closed
  • Created 5 years ago
  • Comments:27 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
MelbourneDevelopercommented, Mar 15, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found