This library aims to provide easy to use ICommand implementations for use in viewmodels.
class | summary |
---|---|
ConcurrentCommand<TArgument> |
A Task based ICommand implementation supporting fluent configuration via IScarletCommandBuilder . |
public class SomeClass
{
public ICommand Command { get; }
public SomeClass(IScarletCommandBuilder commandBuilder)
{
Command = commandBuilder
.Create(Do, CanDo)
.WithSingleExecution() // prevent from running multiple instances of this command at the same time
.WithBusyNotification(BusyStack) // notify an IBusyStack instance that this command is running
.WithAsyncCancellation() // use an async ICommand implementation for cancellation support
.Build();
}
private Task Do(CancellationToken token)
{
return Task.Delay(2000);
}
private bool CanDo()
{
return true;
}
}
ConcurrentCommand<TArgument>
is largely based on Stephen Clearlys blog post: Async Programming : Patterns for Asynchronous MVVM Applications