Closed ChebanovDD closed 1 year ago
When multiple async commands are running at the same time, cancellation only works for the last async command.
StartCommand
CancelCommand
public MainViewModel() { StartCommand = new AsyncCommand(StartAsync).WithCancellation(); CancelCommand = new Command(() => StartCommand.Cancel()); } public IAsyncCommand StartCommand { get; } public ICommand CancelCommand { get; } private async UniTask StartAsync(CancellationToken cancellationToken) { while (cancellationToken.IsCancellationRequested == false) { await UniTask.Delay(1000, cancellationToken: cancellationToken); Debug.Log(nameof(StartAsync)); } }
Only the last command will be canceled.
All running commands should be canceled.
Bug description
When multiple async commands are running at the same time, cancellation only works for the last async command.
Minimal reproduction code and steps
StartCommand
several timesCancelCommand
Current result
Only the last command will be canceled.
Expected result
All running commands should be canceled.