47 lines
2.4 KiB
C#
47 lines
2.4 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT License.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
namespace System.Reactive.Concurrency
|
|
{
|
|
/// <summary>
|
|
/// Represents an object that schedules units of work.
|
|
/// </summary>
|
|
public interface IScheduler
|
|
{
|
|
/// <summary>
|
|
/// Gets the scheduler's notion of current time.
|
|
/// </summary>
|
|
DateTimeOffset Now { get; }
|
|
|
|
/// <summary>
|
|
/// Schedules an action to be executed.
|
|
/// </summary>
|
|
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
|
|
/// <param name="state">State passed to the action to be executed.</param>
|
|
/// <param name="action">Action to be executed.</param>
|
|
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
|
|
IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action);
|
|
|
|
/// <summary>
|
|
/// Schedules an action to be executed after dueTime.
|
|
/// </summary>
|
|
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
|
|
/// <param name="state">State passed to the action to be executed.</param>
|
|
/// <param name="action">Action to be executed.</param>
|
|
/// <param name="dueTime">Relative time after which to execute the action.</param>
|
|
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
|
|
IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action);
|
|
|
|
/// <summary>
|
|
/// Schedules an action to be executed at dueTime.
|
|
/// </summary>
|
|
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
|
|
/// <param name="state">State passed to the action to be executed.</param>
|
|
/// <param name="action">Action to be executed.</param>
|
|
/// <param name="dueTime">Absolute time at which to execute the action.</param>
|
|
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
|
|
IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action);
|
|
}
|
|
}
|