2023-10-11 07:01:44 +03:00
|
|
|
using Eto.Forms;
|
|
|
|
|
|
|
|
namespace NAPS2.EtoForms;
|
|
|
|
|
|
|
|
public class EtoInvoker : IInvoker
|
|
|
|
{
|
|
|
|
private readonly Application _application;
|
|
|
|
|
|
|
|
public EtoInvoker(Application application)
|
|
|
|
{
|
|
|
|
_application = application;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Invoke(Action action)
|
|
|
|
{
|
2024-03-16 04:55:50 +03:00
|
|
|
EtoPlatform.Current.Invoke(_application, action);
|
2023-10-11 07:01:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void InvokeDispatch(Action action)
|
|
|
|
{
|
2024-03-16 04:55:50 +03:00
|
|
|
EtoPlatform.Current.AsyncInvoke(_application, action);
|
2023-10-11 07:01:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public T InvokeGet<T>(Func<T> func)
|
|
|
|
{
|
|
|
|
T value = default!;
|
2024-03-16 04:55:50 +03:00
|
|
|
EtoPlatform.Current.Invoke(_application, () => value = func());
|
2023-10-11 07:01:44 +03:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|