C
C#4mo ago
Steff

✅ CancellationtokenSource and Cancel Task

Hello Guys, Small question. If i Cancel a Task with the CancellationtokenSource, I need for other Task's a New CancellationtokenSource?
6 Replies
canton7
canton74mo ago
I'm not sure what you mean by that I'm afraid You can only cancel a CancellationTokenSource once. Cancelling a CancellationTokenSource will cancel all CancellationTokens created from that TCS
Steff
SteffOP4mo ago
Without knowing the content, I have a small question that could actually answer everything for me: If I cancel a task with CancellationTokenSource, is the CancellationTokenSource then "used up" and I have to create a new CancellationTokenSource for the next task?
canton7
canton74mo ago
Once you cancel a CancellationTokenSource, you can't un-cancel it So yes, if you need another, new CancellationToken which isn't cancelled already, you'll need a new CancellationTokenSource
Steff
SteffOP4mo ago
A big, big thank you! You've solved pretty much every problem I have at the moment 😄
canton7
canton74mo ago
Good to hear! $close
MODiX
MODiX4mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server