ScheduledItem<TAbsolute, TValue>
public sealed class ScheduledItem<TAbsolute, TValue> : ScheduledItem<TAbsolute> where TAbsolute : IComparable<TAbsolute>
Represents a scheduled work item based on the materialization of an IScheduler.Schedule method call.
using System.Collections.Generic;
namespace System.Reactive.Concurrency
{
public sealed class ScheduledItem<TAbsolute, TValue> : ScheduledItem<TAbsolute> where TAbsolute : IComparable<TAbsolute>
{
private readonly IScheduler _scheduler;
private readonly TValue _state;
private readonly Func<IScheduler, TValue, IDisposable> _action;
public ScheduledItem(IScheduler scheduler, TValue state, Func<IScheduler, TValue, IDisposable> action, TAbsolute dueTime, IComparer<TAbsolute> comparer)
: base(dueTime, comparer)
{
if (scheduler == null)
throw new ArgumentNullException("scheduler");
_scheduler = scheduler;
_state = state;
if (action == null)
throw new ArgumentNullException("action");
_action = action;
}
public ScheduledItem(IScheduler scheduler, TValue state, Func<IScheduler, TValue, IDisposable> action, TAbsolute dueTime)
: this(scheduler, state, action, dueTime, (IComparer<TAbsolute>)Comparer<TAbsolute>.Default)
{
}
protected override IDisposable InvokeCore()
{
return _action(_scheduler, _state);
}
}
}