54 lines
2.2 KiB
C#
54 lines
2.2 KiB
C#
namespace JD.Threading.Dispatch
|
|
{
|
|
public interface IThreadDispatchStrategy
|
|
{
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Returns false if the property is called on the main thread of the strategy (usually the UI thread).
|
|
/// </summary>
|
|
bool InvokeRequired { get; }
|
|
|
|
/// <summary>
|
|
/// Returns false if the property is called on any thread managed by the strategy (usually the UI thread AND the long operation thread).
|
|
/// </summary>
|
|
bool LongOperationInvokeRequired { get; }
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Dispatches the given <paramref name="action"/> synchronously.
|
|
/// </summary>
|
|
void Dispatch(System.Action action);
|
|
|
|
/// <summary>
|
|
/// Dispatches the given <paramref name="action"/> asynchronously, if possible. Otherwise, dispatch it synchronously.
|
|
/// </summary>
|
|
void DispatchAsync(System.Action action, bool forceAsync);
|
|
|
|
/// <summary>
|
|
/// Creates a spacetime rift to allow the <paramref name="action"/> to run while the UI thread still feels responsive to the user.
|
|
/// Blocks until the operation is finished.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Effectively, there is only one thread operating on the data at the same time, but the UI thread will keep on responding to
|
|
/// a limited set of Win32 messages to mimic responsiveness.
|
|
/// </remarks>
|
|
void DoLongOperation(System.Action action);
|
|
|
|
/// <summary>
|
|
/// Creates a spacetime rift to allow the <paramref name="action"/> to run while the UI thread still feels responsive to the user.
|
|
/// Returns immediately. To be effective, you must return control as soon as possible to the message loop. In other words, don't
|
|
/// temper with the data after calling this method.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Effectively, there is only one thread operating on the data at the same time, but the UI thread will keep on responding to
|
|
/// a limited set of Win32 messages to mimic responsiveness.
|
|
/// </remarks>
|
|
void DoLongOperationAsync(System.Action action);
|
|
|
|
#endregion
|
|
}
|
|
}
|