register method

CancellationTokenRegistration register(
  1. CallbackRegistration? callback, [
  2. Object? state
])

Registers a callback that will be called when the CancellationToken is canceled.

Implementation

CancellationTokenRegistration register(CallbackRegistration? callback,
    [Object? state]) {
  var source = _source;

  if (callback == null) {
    throw ArgumentError.notNull('callback');
  }

  if (source != null) {
    return source.register(callback, state);
  }

  return CancellationTokenRegistration(0, null);
}