cancellation-token Questions
3
Solved
Does it make any sense to use a struct instead of a reference type in case of CancellationToken?
I see one possible disadvantage, it will be copied all the way down in methods chain as I pass it a...
Kickapoo asked 22/10, 2018 at 20:50
5
Is this a good practice to always add CancellationToken in my actions no matter if operation is long or not?
I'm currently adding it to every action and I don't know if it's right or wrong.
[ApiC...
Moniz asked 14/5, 2018 at 11:51
5
Solved
I'd like to be able to pass cancellation tokens via dependency injection instead of as parameters every time. Is this a thing?
We have an asp.net-core 2.1 app, where we pass calls from controllers ...
Melbourne asked 29/9, 2020 at 15:18
1
Solved
Update: 're-submitted' with hopefully easier code for responders to examine and run locally to reproduce the problem.
TLDR; I think my questions below stem from a lack of experience with multi-thre...
Mercaptide asked 19/6, 2023 at 17:16
2
Solved
I have the following architecture:
Web Site -calls-> Proxy Api -calls-> External Api
From the website, I have to make <= 25 calls from the web site to the proxy api. My goal is to call a...
Newlywed asked 18/6, 2023 at 18:5
3
I am developing a Function in Azure with Cancellation Token. Its an Http Trigger.
I pass in a Cancellation Token in in the method parameters.
Its long running function. And I cancel the request i...
Oribelle asked 13/2, 2020 at 7:10
6
Solved
I am trying to delay the processing of a method (SubmitQuery() in the example) called from an keyboard event in WinRT until there has been no further events for a time period (500ms in this case).
...
Binion asked 11/12, 2013 at 1:59
0
According to Scalability in ASP.NET web APIs with Cancellation Tokens, CancellationTokens should be used only for HTTP GET Requests:
Requests that can have side effects, such as creating, updating...
Gileadite asked 11/3, 2023 at 15:39
3
Solved
I want to use lock or a similar synchronization to protect a critical section. At the same time I want to listen to a CancellationToken.
Right now I'm using a mutex like this, but mutex doesn't ha...
Astonishing asked 14/9, 2011 at 13:5
3
I'm recently learning and using Polly to add resilience to my code, especially for the timeout and retry policies. However, I don't know how to unit test the code with polly. To be more specific, I...
Fornication asked 2/4, 2019 at 20:2
3
Solved
I create a BackgroundService like this:
public class CustomService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
do
{
//...
await Ta...
Flowage asked 9/6, 2021 at 6:5
2
Solved
I observed a strange phenomenon that occurs sometimes with an Rx query I wrote, that involves a CancellationToken. Two callbacks are registered to the same CancellationToken, one outside of the que...
Brookbrooke asked 14/3, 2021 at 23:29
4
Solved
How can I pause the executing until the cancellation is requested?
var cts = new CancellationTokenSource();
Task.Run(() =>
{
// Wait for the Cancel...
Console.WriteLine("Canceled!");
});
C...
Protomartyr asked 9/10, 2016 at 10:56
1
Solved
In my application I need to schedule executing of some Actions with delay. It's like setTimeout in JavaScript. Also, when app execution ends I need to cancel all scheduled executions that have not ...
Fulcher asked 12/3, 2022 at 9:59
2
Solved
I was experimenting with how to break out of a ForEachAsync loop. break doesn't work, but I can call Cancel on the CancellationTokenSource. The signature for ForEachAsync has two tokens - one as a ...
Yardman asked 1/12, 2021 at 21:15
2
Solved
I often see the following code which is the first view looks good since one is used to check a precondition before doing something else.
But when one reads the name of the method it feels like the ...
Elea asked 10/11, 2021 at 9:21
5
Solved
Looking at the implementation of CancellationToken.None, it is simply returning default(CancellationToken). However, I see no reference in CancellationToken's documentation that the two are equival...
Louvar asked 23/10, 2013 at 13:52
2
Solved
Question: Is there a way to associate a CancellationToken with the Task returned from an async method?
Generally, a Task will end up in the Canceled state if an OperationCancelledException is throw...
Kibe asked 6/3, 2013 at 20:29
5
Solved
When I cancel my async method with the following content by calling the Cancel() method of my CancellationTokenSource, it will stop eventually. However since the line Console.WriteLine(await reader...
Outbid asked 20/2, 2015 at 10:19
1
Solved
I developed a C# based Windows Service which runs all of its logic in several different tasks.
To allow the service to shutdown gracefully when it is being stopped, I am using a CancellationToken w...
Underhung asked 6/10, 2021 at 14:57
3
Solved
I have been playing round with the Async CTP this morning and have a simple program with a button and a label. Click the button and it starts updating the label, stop the button it stops writing to...
Olinger asked 17/2, 2012 at 17:11
2
Solved
I am currently implementing some services based on the design of the UserManger of Asp.Net Core Identity.
In the Implementation i wondered how the usermanager is possible to support cancellation i...
Iolanthe asked 8/11, 2019 at 9:8
1
Solved
I'm using an async api which supports cancellation and I'm passing to that api a CancellationToken instance. As usual, if the cancellation is requested on the passed token, the api that I'm invokin...
Tutuila asked 21/4, 2021 at 21:36
0
The Rx library includes operators that accept lambda parameters, and some of these lambdas are provided with a CancellationToken that is controlled by the library itself. Some examples of these ope...
Elevated asked 26/2, 2021 at 8:18
1
I want to cancel an async function on reentrancy, so that the work do not get stacked up and unneeded work is prevented.
e.g. my file scanning can take up to 8 seconds, but when I change the folder...
Mainstream asked 25/2, 2021 at 16:36
1 Next >
© 2022 - 2024 — McMap. All rights reserved.