Closed tymtam2 closed 5 years ago
Yep, that's fine, it'll just pause until the token fires. I'm assuming that you don't have another way to wait on the other long running tasks itself?
Hi @davidfowl
I'm planning to run the long running/forever tasks in a fire_and_forget way.
Are you suggesting that
var tA = StartForeverTaskA();
var tB = StartForeverTaskB();
var tC = StartForeverTaskC();
var tD = StartForeverTaskD();
await Task.WhenAll(new [] {tA,tB,tC,tD});
or even
StartForeverTaskA(); // fire and forget
StartForeverTaskB(); // fire and forget
StartForeverTaskC(); // fire and forget
await StartForeverTaskD(); //never returns;
would be equally 'correct'?
Yes, passing the token to each of them so that they would try to unwind if the stoppingToken is fired.
We periodically close 'discussion' issues that have not been updated in a long period of time.
We apologize if this causes any inconvenience. We ask that if you are still encountering an issue, please log a new issue with updated information and we will investigate.
Let's say my application has been built in the following way:
And then
My question is:
Is
return Task.Delay(Timeout.Infinite, stoppingToken);
inExecuteAsync
the correct canonical way to keep the service 'alive'?