JD2022-TU1/main/tools/framework/JD.Threading/Dispatch/Dispatcher.cs

37 lines
901 B
C#

namespace JD.Threading.Dispatch
{
public abstract class Dispatcher
{
#region Properties
/// <summary>
/// Internal.
/// </summary>
public abstract IThreadDispatchStrategy Strategy
{
get;
}
#endregion
#region Methods
/// <summary>
/// Dispatches the given <paramref name="action"/> synchronously.
/// </summary>
public void Dispatch(System.Action action)
{
Strategy.Dispatch(action);
}
/// <summary>
/// Dispatches the given <paramref name="action"/> asynchronously, if possible. Otherwise, dispatch it synchronously.
/// </summary>
public void DispatchAsync(System.Action action, bool forceAsync = false)
{
Strategy.DispatchAsync(action, forceAsync);
}
#endregion
}
}