using System; using System.Threading.Tasks; namespace ZeroLevel.Services.Shedulling { public interface IAsyncSheduller : IDisposable { #region One time events long RemindAsyncAfter(TimeSpan timespan, Func callback); long RemindAsyncAt(DateTime date, Func callback); #endregion One time events #region Repitable behaviour /// /// Performs an action once a period, while the period is recalculated according to the transferred function at each re-creation of the task. /// /// Function to calculate the next period /// Action /// Task ID long RemindAsyncEveryNonlinearPeriod(Func nextEventPeriodCalcFunction, Func callback, bool breakWherError = false); /// /// Performs an action once a period, while the period is recalculated according to the transferred function at each re-creation of the task. /// /// The function to calculate the period to the first execution /// The function for calculating the period until subsequent performances /// Action /// Task ID long RemindAsyncEveryNonlinearPeriod(Func firstEventPeriodCalcFunction, Func nextEventPeriodCalcFunction, Func callback, bool breakWherError = false); /// /// Performs an action once per period, while the date is recalculated from the function transferred each time the task is recreated. /// /// The function to calculate the next date /// Action /// Task ID long RemindAsyncEveryNonlinearDate(Func nextEventDateCalcFunction, Func callback, bool breakWherError = false); long RemindAsyncEveryNonlinearDate(DateTime firstTime, Func nextEventDateCalcFunction, Func callback, bool breakWherError = false); /// /// Performs an action once per period, while the date is recalculated from the function transferred each time the task is recreated. /// /// The function to calculate the first run date /// The function to calculate the next date /// Action /// Task ID long RemindAsyncEveryNonlinearDate(Func firstEventDateCalcFunction, Func nextEventDateCalcFunction, Func callback, bool breakWherError = false); /// /// Performs an action once in a specified period /// /// Period /// Action /// Task ID long RemindAsyncEvery(TimeSpan timespan, Func callback, bool breakWherError = false); /// /// Performs an action once in a specified period /// /// Period to first run /// Period /// Action /// Task ID long RemindAsyncEvery(TimeSpan first, TimeSpan next, Func callback, bool breakWherError = false); long RemindAsyncWhile(TimeSpan period, Func> callback, Action continueWith = null, bool breakWherError = false); #endregion Repitable behaviour #region Sheduller control void Pause(); void Resume(); void Clean(); bool Remove(long key); #endregion Sheduller control } }