You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to create an async command that supports cancellation, use the `WithCancellation` extension method.
429
439
430
440
```csharp
@@ -446,22 +456,13 @@ public class MyViewModel : IBindingContext
446
456
447
457
privatevoidCancel()
448
458
{
449
-
// If the underlying command is not running, or
450
-
// if it does not support cancellation, this method will perform no action.
459
+
// If the underlying command is not running, this method will perform no action.
451
460
MyAsyncCommand.Cancel();
452
461
}
453
462
}
454
463
```
455
464
456
-
If the command supports cancellation, previous invocations will automatically be canceled if a new one is started.
457
-
458
-
> **Note:** You need to import the [UniTask](https://github.com/Cysharp/UniTask) package in order to use async commands.
459
-
460
-
### AsyncLazyCommand & AsyncLazyCommand\<T\>
461
-
462
-
The `AsyncLazyCommand` and `AsyncLazyCommand<T>` are have the same functionality as the `AsyncCommand`'s, except they prevent the same async command from being invoked concurrently multiple times.
463
-
464
-
Let's imagine a scenario similar to the one described in the `AsyncCommand` sample, but a user clicks the `Download Image` button several times while the async operation is running. In this case, `AsyncLazyCommand` will ignore all clicks until previous async operation has completed.
465
+
If a command supports cancellation and the `AllowConcurrency` property is set to `true`, all running commands will be canceled.
465
466
466
467
> **Note:** You need to import the [UniTask](https://github.com/Cysharp/UniTask) package in order to use async commands.
0 commit comments