This is an implementation of ICommand that can process asynchronous operation.

You can define the ExecuteAsync delegate, then AsyncCommand will execute it asynchronously.
And you can provide OnCompleted, OnError, OnCanceled delegate to handle these situations. They will be executed on the thread that command was created.

When AsyncCommand is executed, it creates IAsyncJob instance. This object do asynchronous operation.
IAsyncJob implements INotifyPropertyChanged, so you can watch the state of asynchronous operation.

The implementation of IAsyncCommand and IAsyncJob on this library works shown as below:
1.Execute IAsyncCommand.
(IAsyncCommand creates IAsyncJob and scheduling it for execution to assigned TaskScheduler.)
2.When IAsyncJob starts running, it notifies properties as follows:
IsRunning = true;
(Do ExecuteAsync)
IsRunning = false;
IsNotifying = true;
(Do notifying, call OnCompleted, OnError or OnCanceled)
IsNotifying = false;
IsCompleted = true;

Please let me know any suggestions :)


Last edited Nov 10, 2014 at 3:16 PM by hyge, version 7