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