Closed
Description
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
- Execute
StartCommand
several times - Execute
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));
}
}
Current result
Only the last command will be canceled.
Expected result
All running commands should be canceled.