Class LocalScheduler
Abstract base class for machine-local schedulers, using the local system clock for time-based operations.
Inheritance
Inherited Members
Namespace: System.Reactive.Concurrency
Assembly: System.Reactive.Core.dll
Syntax
public abstract class LocalScheduler : IScheduler, IStopwatchProvider, IServiceProvider
Properties
| Improve this Doc View SourceNow
Gets the scheduler's notion of current time.
Declaration
public virtual DateTimeOffset Now { get; }
Property Value
Type | Description |
---|---|
DateTimeOffset |
Methods
| Improve this Doc View SourceGetService(Type)
Discovers scheduler services by interface type. The base class implementation returns requested services for each scheduler interface implemented by the derived class. For more control over service discovery, derived types can override this method.
Declaration
protected virtual object GetService(Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
Type | serviceType | Scheduler service interface type to discover. |
Returns
Type | Description |
---|---|
Object | Object implementing the requested service, if available; null otherwise. |
Schedule<TState>(TState, DateTimeOffset, Func<IScheduler, TState, IDisposable>)
Schedules an action to be executed at dueTime.
Declaration
public virtual IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action)
Parameters
Type | Name | Description |
---|---|---|
TState | state | State passed to the action to be executed. |
DateTimeOffset | dueTime | Absolute time at 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. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Schedule<TState>(TState, Func<IScheduler, TState, IDisposable>)
Schedules an action to be executed.
Declaration
public virtual 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. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Schedule<TState>(TState, TimeSpan, Func<IScheduler, TState, IDisposable>)
Schedules an action to be executed after dueTime.
Declaration
public abstract 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. |
StartStopwatch()
Starts a new stopwatch object.
Declaration
public virtual IStopwatch StartStopwatch()
Returns
Type | Description |
---|---|
IStopwatch | New stopwatch object; started at the time of the request. |
Remarks
Platform-specific scheduler implementations should reimplement IStopwatchProvider to provide a more efficient IStopwatch implementation (if available).
Explicit Interface Implementations
| Improve this Doc View SourceIServiceProvider.GetService(Type)
Declaration
object IServiceProvider.GetService(Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
Type | serviceType |
Returns
Type | Description |
---|---|
Object |