Replies: 2 comments 2 replies
-
The cancellation token in |
Beta Was this translation helpful? Give feedback.
1 reply
-
@huoyaoyuan - Probably that the @soraphis - Current workaround: public static Task Run(Action<CancellationToken> action, CancellationToken token)
{
// I believe this will be hoisted so that there will be no per-invocation Action instance.
void RunTuple(object? t)
{
// All because we have to unbox the token, alas.
var (inputAction, inputToken) = (Tuple<Action<CancellationToken>, CancellationToken>)t;
inputAction(inputToken);
};
return Task.Factory.StartNew(RunTuple, (action, token), token, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
assume having a cancellable task:
the cancellationToken that is passed to Run could be passed from there as an argument to the taskAction, passing it by parameter instead of capturing it.
Beta Was this translation helpful? Give feedback.
All reactions