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.

[FeatureRequest] Add overload with cancellation token to the Listen() method

See original GitHub issue

Motivation: We start Gofer task client from .net core hosted service. We use the BackgroundService.ExecuteAsync() method that expects that underlying code will exit on cancellation. We’ve imitate cancellation support with

cancellation.Register(()=>taskClient.CancelListen())

but I think it will be good to have such feature out of the box.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
brthorcommented, Jul 18, 2020

I don’t see any reason why an overload couldn’t be added that takes a cancellation token. Personally I have not used the pattern much but I understand it’s widely spread throughout .NET.

Are you interested in making a PR for this feature @ig-sinicyn ?

1reaction
brthorcommented, Jul 11, 2020

Thanks for the feature request @ig-sinicyn .

Can you provide an example of how you expect the code should look if the API was changed to accommodate this use case?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add overloads for CancellationToken.[Unsafe]Register that ...
Feature request : Add overloads for CancellationToken. [Unsafe]Register that pass the CancellationToken to the registered function #40475.
Read more >
Adding abort all tasks using a single cancellation token
I was assigned to add an abort option which should end all the current running tasks. Because the system was already implemented, passing ......
Read more >
CA2016: Forward the CancellationToken parameter to ...
This rule analyzes method definitions that take a CancellationToken as their last parameter, then analyzes all methods invoked in its body.
Read more >
A Deep Dive into C#'s CancellationToken | by Mitesh Shah
Once the IsCancellationRequested property in a cancellation token is set to true , it can't be set to false again and you cant...
Read more >
Incorrect "Method has overload with cancellation support ...
Incorrect "Method has overload with cancellation support" quick fix when method has an argument of type CancellationTokenSource ; Subsystem, Code Analysis - C#....
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