Commands auf Async umgestellt

This commit is contained in:
HuskyTeufel
2021-09-15 19:12:31 +02:00
parent 00718f9821
commit e0c9839275
13 changed files with 242 additions and 90 deletions

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace DaSaSo.ViewModel.Commands
{
public abstract class AsyncCommandBase : ICommand
{
bool _isExecuting = false;
public event EventHandler? CanExecuteChanged;
public bool IsExecuting
{
get => _isExecuting;
set
{
_isExecuting = value;
CanExecuteChanged?.Invoke(this, new EventArgs());
}
}
public bool CanExecute(object? parameter)
{
return !IsExecuting;
}
public async void Execute(object? parameter)
{
IsExecuting = true;
await ExecuteAsync(parameter);
IsExecuting = false;
}
public abstract Task ExecuteAsync(object? parameter);
}
}