public void Schedule(IBotComponent component) { var nextTime = DateTimeOffset.UtcNow + component.Interval; _schedule.Add(nextTime, component); if (_schedule.Count == 1 || _schedule.FirstOrDefault().Key == nextTime) { _timer.Change(component.Interval, TimeSpan.FromMilliseconds(-1)); } }
public void Unschedule(IBotComponent component) { var entry = _schedule.FirstOrDefault(x => x.Value == component); if (entry.Value == null) { return; } _schedule.Remove(entry.Key); }
/// <summary> /// Adds a component to the bot engine. /// </summary> /// <param name="component">The compoment to add</param> public void AddComponent(IBotComponent component) { _scheduler.Schedule(component); }