[FeatureRequest] Add overload with cancellation token to the Listen() method
See original GitHub issueMotivation: 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:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top 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 >
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
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 ?
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?