Ejemplo n.º 1
0
 /// <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="callback">The event to call when the timer ticks.</param>
 public DispatcherTimer(TimeSpan interval, DispatcherPriority priority, EventHandler callback) : this(priority)
 {
     _priority = priority;
     Interval  = interval;
     Tick     += callback;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Post action that will be invoked on main thread
 /// </summary>
 /// <param name="action">The method.</param>
 ///
 /// <param name="priority">The priority with which to invoke the method.</param>
 internal void Post(Action action, DispatcherPriority priority)
 {
     AddJob(new Job(action, priority, true));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherTimer"/> class.
 /// </summary>
 /// <param name="priority">The priority to use.</param>
 public DispatcherTimer(DispatcherPriority priority)
 {
     _priority = priority;
 }
Ejemplo n.º 4
0
 /// <inheritdoc/>
 public Task <TResult> InvokeAsync <TResult>(Func <TResult> function, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     Contract.Requires <ArgumentNullException>(function != null);
     return(_jobRunner.InvokeAsync(function, priority));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Job"/> class.
 /// </summary>
 /// <param name="action">The method to call.</param>
 /// <param name="priority">The job priority.</param>
 /// <param name="throwOnUiThread">Do not wrap exception in TaskCompletionSource</param>
 public Job(Action action, DispatcherPriority priority, bool throwOnUiThread)
 {
     _action  = action;
     Priority = priority;
     _taskCompletionSource = throwOnUiThread ? null : new TaskCompletionSource <object>();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Use this method to ensure that more prioritized tasks are executed
 /// </summary>
 /// <param name="minimumPriority"></param>
 public void RunJobs(DispatcherPriority minimumPriority) => _jobRunner.RunJobs(minimumPriority);
Ejemplo n.º 7
0
 /// <inheritdoc/>
 public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     Contract.Requires <ArgumentNullException>(action != null);
     return(_jobRunner.InvokeAsync(action, priority));
 }
Ejemplo n.º 8
0
 /// <inheritdoc/>
 public void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     _jobRunner?.Post(action, priority);
 }
Ejemplo n.º 9
0
 /// <inheritdoc/>
 public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     Contract.Requires <ArgumentNullException>(action != null);
     _jobRunner.Post(action, priority);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Post action that will be invoked on main thread
 /// </summary>
 /// <param name="action">The method to call.</param>
 /// <param name="parameter">The parameter of method to call.</param>
 /// <param name="priority">The priority with which to invoke the method.</param>
 internal void Post <T>(Action <T> action, T parameter, DispatcherPriority priority)
 {
     AddJob(new Job <T>(action, parameter, priority, true));
 }
Ejemplo n.º 11
0
 /// <inheritdoc/>
 public Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     return(_jobRunner?.InvokeAsync(action, priority));
 }
Ejemplo n.º 12
0
 /// <inheritdoc/>
 public Task <TResult> InvokeAsync <TResult>(Func <TResult> function, DispatcherPriority priority = default)
 {
     _ = function ?? throw new ArgumentNullException(nameof(function));
     return(_jobRunner.InvokeAsync(function, priority));
 }
Ejemplo n.º 13
0
 /// <inheritdoc/>
 public Task InvokeAsync(Action action, DispatcherPriority priority = default)
 {
     _ = action ?? throw new ArgumentNullException(nameof(action));
     return(_jobRunner.InvokeAsync(action, priority));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Use this method to check if there are more prioritized tasks
 /// </summary>
 /// <param name="minimumPriority"></param>
 public bool HasJobsWithPriority(DispatcherPriority minimumPriority) =>
 _jobRunner.HasJobsWithPriority(minimumPriority);
Ejemplo n.º 15
0
 /// <inheritdoc/>
 public void Post(SendOrPostCallback action, object?arg, DispatcherPriority priority = default)
 {
     _ = action ?? throw new ArgumentNullException(nameof(action));
     _jobRunner.Post(action, arg, priority);
 }
Ejemplo n.º 16
0
 /// <inheritdoc/>
 public void Post(Action action, DispatcherPriority priority = default)
 {
     _ = action ?? throw new ArgumentNullException(nameof(action));
     _jobRunner.Post(action, priority);
 }