C
C#2mo ago
Len

Async function

Hello guys, what is the best way to stop a async function? I made a async function, which monitors if a key is pressed. Should I use the cancel Token? And is Task<> with Return the only why to get something back from the function?
6 Replies
Jimmacle
Jimmacle2mo ago
yes and yes cancellation tokens are good for cancelling long running operations and async methods must return a Task (with one specific exception)
Len
Len2mo ago
But their is no possible way, that is similar to ref Right?
Jimmacle
Jimmacle2mo ago
i'm not sure what that means
Len
Len2mo ago
ref - > reference is Not possible for async, is their a other way
Jimmacle
Jimmacle2mo ago
like ref arguments? no
Len
Len2mo ago
Ok Thank you
Want results from more Discord servers?
Add your server
More Posts