/// <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; }
/// <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)); }
/// <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; }
/// <inheritdoc/> public Task <TResult> InvokeAsync <TResult>(Func <TResult> function, DispatcherPriority priority = DispatcherPriority.Normal) { Contract.Requires <ArgumentNullException>(function != null); return(_jobRunner.InvokeAsync(function, priority)); }
/// <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>(); }
/// <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);
/// <inheritdoc/> public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { Contract.Requires <ArgumentNullException>(action != null); return(_jobRunner.InvokeAsync(action, priority)); }
/// <inheritdoc/> public void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { _jobRunner?.Post(action, priority); }
/// <inheritdoc/> public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { Contract.Requires <ArgumentNullException>(action != null); _jobRunner.Post(action, priority); }
/// <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)); }
/// <inheritdoc/> public Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { return(_jobRunner?.InvokeAsync(action, priority)); }
/// <inheritdoc/> public Task <TResult> InvokeAsync <TResult>(Func <TResult> function, DispatcherPriority priority = default) { _ = function ?? throw new ArgumentNullException(nameof(function)); return(_jobRunner.InvokeAsync(function, priority)); }
/// <inheritdoc/> public Task InvokeAsync(Action action, DispatcherPriority priority = default) { _ = action ?? throw new ArgumentNullException(nameof(action)); return(_jobRunner.InvokeAsync(action, priority)); }
/// <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);
/// <inheritdoc/> public void Post(SendOrPostCallback action, object?arg, DispatcherPriority priority = default) { _ = action ?? throw new ArgumentNullException(nameof(action)); _jobRunner.Post(action, arg, priority); }
/// <inheritdoc/> public void Post(Action action, DispatcherPriority priority = default) { _ = action ?? throw new ArgumentNullException(nameof(action)); _jobRunner.Post(action, priority); }