withArgument<T, R> static method
ZonedWork<R>
withArgument<T, R>(
- T argument,
- FutureOr<
R> computation(- T arg
- CancellationToken? token,
Creates an instance of ZonedWork.
Parameters:
argument: Argument to pass to thecomputationfunction.computation: A function that represents a computation.token: Cancellation token used for canceling the execution of computation.
If the token parameter is specified, it can be retrieved in the
computation] body by calling Task.token.
Token-based cancellation is a very flexible cancellation method,
implemented solely based on the cancellation request processing logic.
Implementation
static ZonedWork<R> withArgument<T, R>(
T argument,
FutureOr<R> Function(T arg) computation, {
CancellationToken? token,
}) {
return ZonedWork(() => computation(argument), token: token);
}