Class TaskPoolScheduler
Represents an object that schedules units of work on the Task Parallel Library (TPL) task pool.
Inherited Members
Namespace: System.Reactive.Concurrency
Assembly: System.Reactive.PlatformServices.dll
Syntax
public sealed class TaskPoolScheduler : LocalScheduler, IScheduler, IStopwatchProvider, IServiceProvider, ISchedulerLongRunning, ISchedulerPeriodic
Constructors
| Improve this Doc View SourceTaskPoolScheduler(TaskFactory)
Creates an object that schedules units of work using the provided TaskFactory.
Declaration
public TaskPoolScheduler(TaskFactory taskFactory)
Parameters
Type | Name | Description |
---|---|---|
TaskFactory | taskFactory | Task factory used to create tasks to run units of work. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Properties
| Improve this Doc View SourceDefault
Gets an instance of this scheduler that uses the default TaskScheduler.
Declaration
public static TaskPoolScheduler Default { get; }
Property Value
Type | Description |
---|---|
TaskPoolScheduler |
Methods
| Improve this Doc View SourceSchedule<TState>(TState, Func<IScheduler, TState, IDisposable>)
Schedules an action to be executed.
Declaration
public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action)
Parameters
Type | Name | Description |
---|---|---|
TState | state | State passed to the action to be executed. |
Func<IScheduler, TState, IDisposable> | action | Action to be executed. |
Returns
Type | Description |
---|---|
IDisposable | The disposable object used to cancel the scheduled action (best effort). |
Type Parameters
Name | Description |
---|---|
TState | The type of the state passed to the scheduled action. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Schedule<TState>(TState, TimeSpan, Func<IScheduler, TState, IDisposable>)
Schedules an action to be executed after dueTime.
Declaration
public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
Parameters
Type | Name | Description |
---|---|---|
TState | state | State passed to the action to be executed. |
TimeSpan | dueTime | Relative time after which to execute the action. |
Func<IScheduler, TState, IDisposable> | action | Action to be executed. |
Returns
Type | Description |
---|---|
IDisposable | The disposable object used to cancel the scheduled action (best effort). |
Type Parameters
Name | Description |
---|---|
TState | The type of the state passed to the scheduled action. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ScheduleLongRunning<TState>(TState, Action<TState, ICancelable>)
Schedules a long-running task by creating a new task using TaskCreationOptions.LongRunning. Cancellation happens through polling.
Declaration
public IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action)
Parameters
Type | Name | Description |
---|---|---|
TState | state | State passed to the action to be executed. |
Action<TState, ICancelable> | action | Action to be executed. |
Returns
Type | Description |
---|---|
IDisposable | The disposable object used to cancel the scheduled action (best effort). |
Type Parameters
Name | Description |
---|---|
TState | The type of the state passed to the scheduled action. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SchedulePeriodic<TState>(TState, TimeSpan, Func<TState, TState>)
Schedules a periodic piece of work by running a platform-specific timer to create tasks periodically.
Declaration
public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action)
Parameters
Type | Name | Description |
---|---|---|
TState | state | Initial state passed to the action upon the first iteration. |
TimeSpan | period | Period for running the work periodically. |
Func<TState, TState> | action | Action to be executed, potentially updating the state. |
Returns
Type | Description |
---|---|
IDisposable | The disposable object used to cancel the scheduled recurring action (best effort). |
Type Parameters
Name | Description |
---|---|
TState | The type of the state passed to the scheduled action. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
StartStopwatch()
Gets a new stopwatch ob ject.
Declaration
public override IStopwatch StartStopwatch()
Returns
Type | Description |
---|---|
IStopwatch | New stopwatch object; started at the time of the request. |