You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Shedulling/IAsyncSheduller.cs

99 lines
4.2 KiB

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

Powered by TurnKey Linux.