mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 06:46:30 +00:00
30 lines
592 B
C#
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);
|
|
}
|
|
}
|
|
|