public static void DispatchFrame(DispatcherPriority priority = DispatcherPriority.Background) { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(priority, new DispatcherOperationCallback((f)=>((DispatcherFrame)f).Continue = false), frame); Dispatcher.PushFrame(frame); }
public static void InvokeIfRequired(this Dispatcher disp, Action dotIt, DispatcherPriority priority) { if (disp.Thread != Thread.CurrentThread) disp.Invoke(priority, dotIt); else dotIt(); }
public virtual void BeginInvoke(DispatcherPriority priority, Delegate method, object arg, params object[] args) { if (!this.uiThreadDispatcher.HasShutdownStarted) { this.uiThreadDispatcher.BeginInvoke(priority, method, arg, args); } }
public virtual void BeginInvoke(DispatcherPriority priority, Delegate method) { if (!this.uiThreadDispatcher.HasShutdownStarted) { this.uiThreadDispatcher.BeginInvoke(priority, method); } }
public LightClawSynchronizationContext(Dispatcher dispatcher, DispatcherPriority priority) { Contract.Requires<ArgumentNullException>(dispatcher != null); this.dispatcher = dispatcher; this.priority = priority; }
public virtual void Invoke(DispatcherPriority priority, Delegate method, object arg) { if (!this.uiThreadDispatcher.HasShutdownStarted) { this.uiThreadDispatcher.Invoke(priority, method, arg); } }
internal DispatcherOperation(Dispatcher dispatcher, Delegate del, DispatcherPriority priority, object[] args) { myDispatcher = dispatcher; myDelegate = del; myPriority = priority; myArgs = args; }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherThrottle" /> class. /// </summary> /// <param name="priority">The priority of the dispatcher.</param> /// <param name="target">The target action to invoke when the throttle condition is hit.</param> public DispatcherThrottle(DispatcherPriority priority, [NotNull] Action target) { Contract.Requires(target != null); _target = target; _priority = priority; }
public DispatcherTimer(Dispatcher dispatcher, ITaskScheduler scheduler, TimeSpan interval, DispatcherPriority priority) { this.dispatcher = dispatcher; this.scheduler = scheduler; this.Interval = interval; this.Priority = priority; }
/// <summary> /// for UI methods to switch current thread to UI thread /// </summary> public static void InvokeIfRequired(this DispatcherObject control, Action methodcall, DispatcherPriority priorityForCall) { if (control.Dispatcher.Thread != Thread.CurrentThread) control.Dispatcher.Invoke(priorityForCall, methodcall); else methodcall(); }
internal DispatcherOperation (Dispatcher dis, DispatcherPriority prio, Delegate d, object arg) : this (dis, prio) { delegate_method = d; delegate_args = new object [1]; delegate_args [0] = arg; }
/// <summary> /// Creates a timer that is bound to the specified dispatcher and /// will be processed at the specified priority, after the /// specified timeout. /// </summary> /// <param name="interval"> /// The interval to tick the timer after. /// </param> /// <param name="priority"> /// The priority to process the timer at. /// </param> /// <param name="callback"> /// The callback to call when the timer ticks. /// </param> /// <param name="dispatcher"> /// The dispatcher to use to process the timer. /// </param> public DispatcherTimer(TimeSpan interval, DispatcherPriority priority, EventHandler callback, Dispatcher dispatcher) // NOTE: should be Priority { // if(callback == null) { throw new ArgumentNullException("callback"); } if(dispatcher == null) { throw new ArgumentNullException("dispatcher"); } if (interval.TotalMilliseconds < 0) throw new ArgumentOutOfRangeException("interval", SR.Get(SRID.TimeSpanPeriodOutOfRange_TooSmall)); if (interval.TotalMilliseconds > Int32.MaxValue) throw new ArgumentOutOfRangeException("interval", SR.Get(SRID.TimeSpanPeriodOutOfRange_TooLarge)); Initialize(dispatcher, priority, interval); Tick += callback; Start(); }
public void Execute(Delegate method, DispatcherPriority priority) { if (application == null) { ExecuteDirectlyOrDuringATest(method); return; } var dispatcher = application.Dispatcher; if ((application != null) && isAsync) { dispatcher.BeginInvoke(method); return; } var notRequireUiThread = dispatcher.CheckAccess(); if (notRequireUiThread) { ExecuteDirectlyOrDuringATest(method); return; } if (isAsync) { dispatcher.BeginInvoke(method, priority); return; } dispatcher.Invoke(method, priority); }
public static void PostAction( this DispatcherObject obj, Action action, DispatcherPriority priority = DispatcherPriority.Input) { obj.Dispatcher.BeginInvoke(priority, action); }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherTimer"/> class. /// </summary> /// <param name="interval">The interval at which to tick.</param> /// <param name="priority">The priority to use.</param> /// <param name="dispatcher">The dispatcher to use.</param> /// <param name="callback">The event to call when the timer ticks.</param> public DispatcherTimer(TimeSpan interval, DispatcherPriority priority, EventHandler callback, Dispatcher dispatcher) { _priority = priority; Dispatcher = dispatcher; Interval = interval; Tick += callback; }
public static void InvokeIfRequired(this Dispatcher dispatcher, Action action, DispatcherPriority priority) { if (!dispatcher.CheckAccess()) dispatcher.Invoke(priority, (Delegate) action); else action(); }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherTimer"/> class. /// </summary> /// <param name="interval">The interval at which to tick.</param> /// <param name="priority">The priority to use.</param> /// <param name="dispatcher">The dispatcher to use.</param> /// <param name="callback">The event to call when the timer ticks.</param> public DispatcherTimer(TimeSpan interval, DispatcherPriority priority, EventHandler callback, Dispatcher dispatcher) { this.priority = priority; this.Dispatcher = dispatcher; this.Interval = interval; this.Tick += callback; }
public DispatcherTimer(TimeSpan timeSpan, DispatcherPriority priority, EventHandler handler, Dispatcher dispatcher) { myTimeSpan = timeSpan; myPriority = priority; myDispatcher = dispatcher; Tick += handler; myTimer.Tick += new EventHandler(myTimer_Tick); }
/// <summary> /// Construct a timer with a certian Priority /// </summary> /// <param name="eve">The event you want to be called on each tick</param> /// <param name="inter">The interval that you want the event to be called</param> /// <param name="dur">The number of times you want the event to be called</param> /// <param name="proi">The proiority of the timer event</param> public gameTimer(EventHandler eve, TimeSpan inter, int dur, DispatcherPriority proi) { interval = inter; duration = dur; timer_event = eve; priority = proi; timer = new DispatcherTimer(priority); }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherUIHandler"/> class. /// </summary> /// <param name="dispatcher">The UI <see cref="Dispatcher"/>.</param> /// <param name="priority">The <see cref="DispatcherPriority"/> to invoke the calls with.</param> public DispatcherUIHandler( Dispatcher dispatcher, DispatcherPriority priority = DispatcherPriority.Normal ) { Ensure.That(dispatcher).NotNull(); Ensure.That(priority).IsDefined(); this.dispatcher = dispatcher; this.priority = priority; }
public static void DoEvents(DispatcherPriority priority) { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke( priority, new DispatcherOperationCallback(ExitFrame), frame); Dispatcher.PushFrame(frame); }
internal DispatcherOperation (Dispatcher dis, DispatcherPriority prio, Delegate d, object arg, object [] args) : this (dis, prio) { delegate_method = d; delegate_args = new object [args.Length + 1]; delegate_args [0] = arg; Array.Copy (args, 0, delegate_args, 1, args.Length); }
public static void DoEvents(DispatcherPriority priority = DispatcherPriority.Background) { DispatcherFrame frame = new DispatcherFrame(); DXSplashScreen.SplashContainer.SplashScreen.Dispatcher.BeginInvoke( priority, new DispatcherOperationCallback(ExitFrame), frame); Dispatcher.PushFrame(frame); }
public static void DoEvents(DispatcherPriority nPrio) { DispatcherFrame nestedFrame = new DispatcherFrame(); DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(nPrio, exitFrameCallback, nestedFrame); Dispatcher.PushFrame(nestedFrame); if (exitOperation.Status != DispatcherOperationStatus.Completed) exitOperation.Abort(); }
public DispatcherTimer(TimeSpan interval, DispatcherPriority priority, EventHandler callback, Dispatcher dispatcher) { this.priority = priority; this.target_dispatcher = dispatcher; this.interval = interval.Ticks; this.callback = callback; }
public static DispatcherOperation BeginInvoke( this IDispatcherService dispatcher, Action action, DispatcherPriority priority ) { return dispatcher.BeginInvoke(action, priority); }
public static void Invoke( this IDispatcherService dispatcher, Action action, DispatcherPriority priority ) { dispatcher.Invoke(action, priority); }
/// <summary> /// Waits until all pending messages up to the specified priority are processed. /// </summary> /// <param name="dispatcher">The dispatcher to wait on.</param> /// <param name="priority">The priority up to which all messages should be processed.</param> public static void ProcessMessages([NotNull] this Dispatcher dispatcher, DispatcherPriority priority) { Contract.Requires(dispatcher != null); var frame = new DispatcherFrame(); dispatcher.BeginInvoke(priority, () => frame.Continue = false); Dispatcher.PushFrame(frame); }
/// <summary> /// Creates a timer that uses the specified Dispatcher to /// process the timer event at the specified priority. /// </summary> /// <param name="priority"> /// The priority to process the timer at. /// </param> /// <param name="dispatcher"> /// The dispatcher to use to process the timer. /// </param> public DispatcherTimer(DispatcherPriority priority, Dispatcher dispatcher) // NOTE: should be Priority { if(dispatcher == null) { throw new ArgumentNullException("dispatcher"); } Initialize(dispatcher, priority, TimeSpan.FromMilliseconds(0)); }
internal DispatcherOperation (Dispatcher dis, DispatcherPriority prio) { dispatcher = dis; priority = prio; if (Dispatcher.HasShutdownFinished) status = DispatcherOperationStatus.Aborted; else status = DispatcherOperationStatus.Pending; }
/// <summary> /// Executes the specified delegate asynchronously with the specified arguments on the thread that the /// System.Windows.Threading.Dispatcher was created on. /// </summary> /// <param name="dispatcher"></param> /// <param name="action"> /// The delegate to a method that takes parameters specified in args, which is pushed onto the /// System.Windows.Threading.Dispatcher event queue. /// </param> /// <param name="priority"> /// The priority, relative to the other pending operations in the System.Windows.Threading.Dispatcher /// </param> /// <returns> /// An object, which is returned immediately after Overload:System.Windows.Threading.Dispatcher.BeginInvoke /// is called, that can be used to interact with the delegate as it is pending /// execution in the event queue. /// </returns> public static DispatcherOperation BeginInvoke(this Dispatcher dispatcher, Action action, DispatcherPriority priority) { return(dispatcher.BeginInvoke(action, priority)); }
public static void WaitForPriority(this Dispatcher @this, DispatcherPriority priority) { @this.Invoke(priority, doNothing); }
/// <summary> /// Executes the specified delegate asynchronously with the specified arguments on the thread that the /// System.Windows.Threading.Dispatcher was created on. /// </summary> /// <param name="dispatcher"></param> /// <param name="action"> /// The delegate to a method that takes parameters specified in args, which is pushed onto the /// System.Windows.Threading.Dispatcher event queue. /// </param> /// <param name="priority"> /// The priority, relative to the other pending operations in the System.Windows.Threading.Dispatcher /// </param> /// <returns> /// An object, which is returned immediately after Overload:System.Windows.Threading.Dispatcher.BeginInvoke /// is called, that can be used to interact with the delegate as it is pending /// execution in the event queue. /// </returns> /// <param name="args">An array of objects to pass as arguments to the given method. Can be null.</param> public static DispatcherOperation BeginInvoke(this Dispatcher dispatcher, Action action, DispatcherPriority priority, params object[] args) { return(dispatcher.BeginInvoke(action, priority, args)); }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherObservableCollection{T}" /> class. /// </summary> /// <param name="provider">The value for the <see cref="DispatcherObservableCollection{T}.Provider" /> property.</param> /// <param name="prio">The value for the <see cref="DispatcherObservableCollection{T}.Priority" /> property.</param> /// <param name="isBackground">The value for the <see cref="DispatcherObservableCollection{T}.IsBackground" /> property.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> is <see langword="null" />. /// </exception> public DispatcherObservableCollection(DispatcherProvider provider, DispatcherPriority prio, bool isBackground) : this(provider, prio, isBackground, new object()) { }
/// <summary> /// Executes the specified delegate asynchronously at the specified priority with the specified arguments on the thread that the Dispatcher was created on if required. /// <para /> /// To check whether this is necessary, it will check whether the current thread has access to the dispatcher. /// </summary> /// <param name="dispatcher">The dispatcher.</param> /// <param name="method">A delegate to a method that takes parameters specified in args, which is pushed onto the Dispatcher event queue.</param> /// <param name="priority">The priority.</param> /// <param name="args">An array of objects to pass as arguments to the given method. Can be <c>null</c>.</param> /// <returns>The DispatcherOperation or <c>null</c> if the action was not dispatched but executed directly.</returns> /// <exception cref="ArgumentNullException">The <paramref name="method" /> is <c>null</c>.</exception> public static DispatcherOperation BeginInvokeIfRequired(this Dispatcher dispatcher, Delegate method, DispatcherPriority priority, params object[] args) { Argument.IsNotNull("method", method); return(BeginInvoke(dispatcher, () => method.DynamicInvoke(args), priority, true)); }
private DispatcherOperation BeginInvoke(Action action, DispatcherPriority priority) { return(_dispatcher.BeginInvoke(action, priority, null)); }
public static void InvokeAsync(DispatcherObject dispatcherObject, Action action, DispatcherPriority priority = DispatcherPriority.Normal, AsyncInvokeMode mode = AsyncInvokeMode.AsyncOnly) { if (dispatcherObject == null || dispatcherObject.Dispatcher == null) { return; } if (mode == AsyncInvokeMode.AllowSyncInvoke && dispatcherObject.Dispatcher.CheckAccess()) { action.Invoke(); } else { dispatcherObject.Dispatcher.BeginInvoke(action, priority); } }
public abstract Task <Canvas> Draw(Dispatcher dispatcher, DispatcherPriority priority, CancellationToken token, DrawingParameters drawingParameters);
/// <summary> /// Initializes a new instance of the <see cref="DispatcherObservableCollection{T}" /> class. /// </summary> /// <param name="provider">The value for the <see cref="DispatcherObservableCollection{T}.Provider" /> property.</param> /// <param name="prio">The value for the <see cref="DispatcherObservableCollection{T}.Priority" /> property.</param> /// <param name="syncRoot">The value for the <see cref="SynchronizedObservableCollection{T}._SYNC" /> field.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> and/or <paramref name="syncRoot" /> are <see langword="null" />. /// </exception> public DispatcherObservableCollection(DispatcherProvider provider, DispatcherPriority prio, object syncRoot) : this(provider, prio, false, syncRoot) { }
public static void WaitForPriority(DispatcherPriority priority) { WaitForPriority(priority, TimeSpan.Zero); }
public static LoadedAssembly Invoke(DispatcherPriority priority, object func, string name) { return(new LoadedAssembly(null, null, null)); }
/// <summary> /// Creates a new instance of the <see cref="DispatcherJobScheduler" /> class. /// </summary> /// <param name="dispObj">The underlying dispatcher object for the timer.</param> /// <param name="provider">The job provider.</param> /// <param name="prio">The priority for the dispatcher timer.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> and/or <paramref name="dispObj" /> are <see langword="null" />. /// </exception> public static DispatcherJobScheduler Create(DispatcherObject dispObj, JobProvider provider, DispatcherPriority prio) { return(Create(dispObj, provider, prio, new object())); }
/// <summary> /// Creates a new instance of the <see cref="DispatcherJobScheduler" /> class. /// </summary> /// <param name="dispObj">The underlying dispatcher object for the timer.</param> /// <param name="provider">The job provider.</param> /// <param name="prio">The priority for the dispatcher timer.</param> /// <param name="syncRoot">The unique object for sync operations.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" />, <paramref name="dispObj" /> and/or <paramref name="syncRoot" /> are <see langword="null" />. /// </exception> public static DispatcherJobScheduler Create(DispatcherObject dispObj, JobProvider provider, DispatcherPriority prio, object syncRoot) { if (dispObj == null) { throw new ArgumentNullException("dispObj"); } return(new DispatcherJobScheduler(provider, prio, delegate(DispatcherJobScheduler scheduler) { return dispObj.Dispatcher; }, syncRoot)); }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherJobScheduler" /> class. /// </summary> /// <param name="provider">The job provider.</param> /// <param name="prio">The priority for the dispatcher timer.</param> /// <param name="syncRoot">The unique object for sync operations.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> and/or <paramref name="syncRoot" /> are <see langword="null" />. /// </exception> public DispatcherJobScheduler(JobProvider provider, DispatcherPriority prio, object syncRoot) : this(provider, prio, GetAppDispatcher, syncRoot) { }
public CustomDispatcherTimer(DispatcherPriority priority) : base(priority) { }
public static async Task InvokeAsync(this Dispatcher dispatcher, Action d, DispatcherPriority dispatcherPriority) { await TaskEx.Run(() => dispatcher.Invoke(d, dispatcherPriority)); }
/// <summary> /// Initializes a new instance of the <see cref="InteropBitmapRenderHandler"/> class. /// </summary> /// <param name="dispatcherPriority">priority at which the bitmap will be updated on the UI thread</param> public IncreaseBufferInteropRenderHandler(DispatcherPriority dispatcherPriority = DispatcherPriority.Render) { this.dispatcherPriority = dispatcherPriority; }
/// <summary> /// Post a queue item at the specified priority /// </summary> internal void Post(DispatcherPriority priority) { DispatcherOperationCallback callback = new DispatcherOperationCallback(Dispatch); Dispatcher.CurrentDispatcher.BeginInvoke(priority, callback, this); }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherObservableCollection{T}" /> class. /// </summary> /// <param name="prio">The value for the <see cref="DispatcherObservableCollection{T}.Priority" /> property.</param> /// <param name="isBackground">The value for the <see cref="DispatcherObservableCollection{T}.IsBackground" /> property.</param> public DispatcherObservableCollection(DispatcherPriority prio, bool isBackground) : this(GetApplicationDispatcher, prio, isBackground) { }
public static void BeginInvoke(DispatcherPriority priority, Action action) { }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherObservableCollection{T}" /> class. /// </summary> /// <param name="prio">The value for the <see cref="DispatcherObservableCollection{T}.Priority" /> property.</param> /// <param name="syncRoot">The value for the <see cref="SynchronizedObservableCollection{T}._SYNC" /> field.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="syncRoot" /> is <see langword="null" />. /// </exception> public DispatcherObservableCollection(DispatcherPriority prio, object syncRoot) : this(GetApplicationDispatcher, prio, syncRoot) { }
public static void QueueExecute(this Dispatcher @this, DispatcherPriority priority, Action action) { @this.BeginInvoke(priority, action); }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherObservableCollection{T}" /> class. /// </summary> /// <param name="prio">The value for the <see cref="DispatcherObservableCollection{T}.Priority" /> property.</param> public DispatcherObservableCollection(DispatcherPriority prio) : this(GetApplicationDispatcher, false) { }
/// <summary> /// Initializes a new instance of the <see cref="DispatcherJobScheduler" /> class. /// </summary> /// <param name="provider">The job provider.</param> /// <param name="prio">The priority for the dispatcher timer.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="provider" /> is <see langword="null" />. /// </exception> public DispatcherJobScheduler(JobProvider provider, DispatcherPriority prio) : this(provider, prio, new object()) { }
/// <summary> /// Creates new instance of helper. /// </summary> /// <param name="dispatcher">Dispatcher to use.</param> /// <param name="priority">Priority of operations.</param> public DispatcherHelper(Dispatcher dispatcher, DispatcherPriority priority = DispatcherPriority.Normal) { Ensure.NotNull(dispatcher, "dispatcher"); this.dispatcher = dispatcher; this.priority = priority; }
/// <summary> /// Executa o delegate de forma assíncrona na prioridade especificada e com a matriz especificada de argumentos na discussão do Dispatcher está associado. /// </summary> /// <param name="priority"></param> /// <param name="method"></param> /// <param name="arg"></param> /// <param name="args"></param> /// <returns></returns> public virtual IDispatcherOperation BeginInvoke(DispatcherPriority priority, Delegate method, object arg, params object[] args) { throw new NotSupportedException(); }
/// <summary> /// Runs <paramref name="action"/>, eventually after <paramref name="delay"/>. /// Parameter <paramref name="priority"/> overrides priority from ctor. /// </summary> /// <param name="action">Action to run.</param> /// <param name="delay">Delay, before executing <paramref name="action"/>.</param> /// <param name="priority">Priority override.</param> public void Run(Action action, int delay = 0, DispatcherPriority priority = DispatcherPriority.Normal) => Run(dispatcher, action, delay, priority);
/// <summary> /// Executa um delegate de forma assincrona. /// </summary> /// <param name="method">Delegate do método que será executado.</param> /// <param name="priority"></param> /// <param name="args">Parametros do método que será executado.</param> /// <returns> /// O valor de retorno do delegate que está sendo /// chamado ou nulo se o delegate não tem valor de retorno. /// </returns> public virtual object Invoke(Delegate method, DispatcherPriority priority, object[] args) { return(Invoke(method, args)); }
/// <summary> /// Executes the specified action asynchronously at the specified priority with the specified arguments on the thread that the Dispatcher was created on if required. /// <para /> /// To check whether this is necessary, it will check whether the current thread has access to the dispatcher. /// </summary> /// <param name="dispatcher">The dispatcher.</param> /// <param name="action">The action.</param> /// <param name="priority">The priority.</param> /// <returns>The DispatcherOperation or <c>null</c> if the action was not dispatched but executed directly.</returns> /// <exception cref="ArgumentNullException">The <paramref name="action" /> is <c>null</c>.</exception> /// <remarks>For target frameworks where the <see cref="Dispatcher" /> class does not contain the <c>Invoke</c> method, the <c>BeginInvoke</c> /// method will be used instead.</remarks> public static DispatcherOperation BeginInvokeIfRequired(this Dispatcher dispatcher, Action action, DispatcherPriority priority) { return(BeginInvoke(dispatcher, action, priority, true)); }
/// <summary> /// Executa o delegate de forma assíncrona na prioridade especificada no segmento Dispatcher está associado. /// </summary> /// <param name="priority"></param> /// <param name="method"></param> /// <returns></returns> public virtual IDispatcherOperation BeginInvoke(DispatcherPriority priority, Delegate method) { throw new NotSupportedException(); }