C
C#8mo 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
Jimmacle8mo 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
LenOP8mo ago
But their is no possible way, that is similar to ref Right?
Jimmacle
Jimmacle8mo ago
i'm not sure what that means
Len
LenOP8mo ago
ref - > reference is Not possible for async, is their a other way
Jimmacle
Jimmacle8mo ago
like ref arguments? no
Len
LenOP8mo ago
Ok Thank you
Want results from more Discord servers?
Add your server