using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Threading; using Tango.FSE.Common.Threading; namespace Tango.FSE.UI.Threading { /// /// Represents the default FSE which will invoke action on the current application dispatcher. /// /// public class DefaultDispatcherProvider : IDispatcherProvider { private Dispatcher _dispatcher; /// /// Initializes a new instance of the class. /// /// The dispatcher. public DefaultDispatcherProvider(Dispatcher dispatcher) { _dispatcher = dispatcher; } /// /// Invokes the specified action asynchronously. /// /// The action. public void Invoke(Action action) { _dispatcher.BeginInvoke(action); } /// /// Invokes the specified action synchronously. /// /// The action. public void InvokeBlock(Action action) { _dispatcher.Invoke(action); } /// /// Forces the dispatcher message loop. /// public void DoEvents() { _dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { })); } } }