adds catch for cancelled exception to return -2

This commit is contained in:
Philipp Häfelfinger 2023-09-11 16:27:41 +02:00
parent ee2e9e3b77
commit 7ac30086c9

View File

@ -8,5 +8,15 @@ public abstract class CancellableAsyncCommand<TSettings> : AsyncCommand<TSetting
protected abstract Task<int> ExecuteAsync(CommandContext context, TSettings settings, CancellationToken cancellation); protected abstract Task<int> ExecuteAsync(CommandContext context, TSettings settings, CancellationToken cancellation);
public sealed override async Task<int> ExecuteAsync(CommandContext context, TSettings settings) => await ExecuteAsync(context, settings, _cancellationTokenSource.Token); public sealed override async Task<int> ExecuteAsync(CommandContext context, TSettings settings)
{
try
{
return await ExecuteAsync(context, settings, _cancellationTokenSource.Token);
}
catch (TaskCanceledException)
{
return -2;
}
}
} }