stop method
Triggered when the application host is performing a graceful shutdown.
Implementation
@override
Future<void> stop(CancellationToken cancellationToken) async {
// Stop called without start
if (_executeOperation == null) {
return Future.value();
}
try {
// Signal cancellation to the executing method
_stoppingCts!.cancel();
} finally {
// Wait until the future completes or the stop token triggers
var c = Completer<void>();
cancellationToken.register((o) {
c.complete();
});
await Future.any([
_executeOperation!.value,
c.future,
]);
}
}