using System.Threading; namespace JD.Threading.Dispatch { /// /// Must be created on the UI thread that it is supposed to represent. /// internal class DefaultMessageLoop : IMessageLoop { #region Variables private readonly WindowsFormsThreadDispatchStrategy m_underlyingStrategy = new WindowsFormsThreadDispatchStrategy(); #endregion #region Properties public bool InvokeRequired { get { return m_underlyingStrategy.InvokeRequired; } } #endregion #region Methods public void Invoke(System.Action action) { m_underlyingStrategy.Dispatch(action); } public void BeginInvoke(System.Action action) { m_underlyingStrategy.DispatchAsync(action, true); } public void WaitAndPump(WaitHandle waitHandle) { Win32MessageLoop.WaitAndPump(waitHandle); } #endregion } }