예제 #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;
 }
예제 #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));
 }
예제 #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;
 }
예제 #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));
 }
예제 #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>();
 }
예제 #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);
예제 #7
0
 /// <inheritdoc/>
 public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     Contract.Requires <ArgumentNullException>(action != null);
     return(_jobRunner.InvokeAsync(action, priority));
 }
예제 #8
0
 /// <inheritdoc/>
 public void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     _jobRunner?.Post(action, priority);
 }
예제 #9
0
 /// <inheritdoc/>
 public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     Contract.Requires <ArgumentNullException>(action != null);
     _jobRunner.Post(action, priority);
 }
예제 #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));
 }
예제 #11
0
 /// <inheritdoc/>
 public Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
 {
     return(_jobRunner?.InvokeAsync(action, priority));
 }
예제 #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));
 }
예제 #13
0
 /// <inheritdoc/>
 public Task InvokeAsync(Action action, DispatcherPriority priority = default)
 {
     _ = action ?? throw new ArgumentNullException(nameof(action));
     return(_jobRunner.InvokeAsync(action, priority));
 }
예제 #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);
예제 #15
0
 /// <inheritdoc/>
 public void Post(SendOrPostCallback action, object?arg, DispatcherPriority priority = default)
 {
     _ = action ?? throw new ArgumentNullException(nameof(action));
     _jobRunner.Post(action, arg, priority);
 }
예제 #16
0
 /// <inheritdoc/>
 public void Post(Action action, DispatcherPriority priority = default)
 {
     _ = action ?? throw new ArgumentNullException(nameof(action));
     _jobRunner.Post(action, priority);
 }