ZonedWork<T> constructor
ZonedWork<T> (
- FutureOr<
T> computation(), { - CancellationToken? token,
Creates an instance of ZonedWork.
Parameters:
computation: A callback 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
ZonedWork(
FutureOr<T> Function() computation, {
CancellationToken? token,
}) : _computation = computation,
_token = token {
_zone = Zone.current.fork(
specification: ZoneSpecification(
createPeriodicTimer: _createPeriodicTimer,
createTimer: _createTimer,
handleUncaughtError: _handleUncaughtError,
registerBinaryCallback: _registerBinaryCallback,
registerUnaryCallback: _registerUnaryCallback,
registerCallback: _registerCallback,
scheduleMicrotask: _scheduleMicrotask,
),
);
}