Files
annotations/Azaion.Common/Services/WpfUICommandDispatcher.cs
T

30 lines
592 B
C#

using System.Windows.Threading;
namespace Azaion.Common.Services;
public class WpfUICommandDispatcher : IUICommandDispatcher
{
private readonly Dispatcher _dispatcher;
public WpfUICommandDispatcher(Dispatcher dispatcher)
{
_dispatcher = dispatcher;
}
public Task ExecuteAsync(Action action)
{
return _dispatcher.InvokeAsync(action).Task;
}
public Task<T> ExecuteAsync<T>(Func<T> func)
{
return _dispatcher.InvokeAsync(func).Task;
}
public void Execute(Action action)
{
_dispatcher.Invoke(action);
}
}