I've got an
async implementation of the
ICommand interface that of course has to implement the method
void Execute(object parameter)
The actual implementation is then async like the following:
public async void Execute(object parameter)
ExecuteAsync method is then defined as follows:
private readonly Func<T, Task> execute;
private bool isExecuting;
public async Task ExecuteAsync(T parameter)
isExecuting = true;
isExecuting = false;
Now I do know that except for EventHandlers
void should be avoided as return type for async methods. However
ICommand is more or less a wrapper to clearly separate the view model from the actual event handlers. So am I fine with this implementation or will I run into problems?
Especially I'd like to know if I can safely use the execute command and rely on the Task to finish before the handler or will the handler complete regardless of the Task's status?