I am wondering why the MVVM command passes light without asynchronous execution? I believe that there are many cases where this can be useful, so let me name it.
Suppose our user interface contains one container containing several screens. The user can close a specific screen or container with multiple screens. Suppose a user executes a close command in a container. The container, in turn, causes the command to close on each screen, and it needs to wait for the screen to close. This in practice can mean data verification. conservation, etc. For this reason, we need to issue an asynchronous call so that the user interface does not respond, and we also need to wait for the task to complete in order to continue.
So, if we have something like this in Command
public RelayCommand CloseCommand { get { return _closeCommand ?? _closeCommand = new RelayCommand( async () => { foreach (var screen in Screens) { if (!await screen.CloseCommand.ExecuteAsync(null)) {
We can also set an additional method on the screen, but, in my opinion, this should be the RelayCommand task, since it already exists.
Or is there another methodology for handling such a scenario?
source share