Example #1
0
 /// <summary>
 /// Runs the specified task periodically, with a specified delay interval.
 /// </summary>
 /// <param name="task">The task.</param>
 /// <param name="delay">The delay.</param>
 /// <returns>The periodically executing task.</returns>
 public static async Task Run(Func <Task> task, TimeSpan delay)
 {
     await PeriodicTask.Run(async (CancellationToken ct) => await task(), delay);
 }
Example #2
0
 /// <summary>
 /// Repeats the specified action a given number of times, with a specified delay interval.
 /// </summary>
 /// <param name="repeats">The repeats.</param>
 /// <param name="task">The task.</param>
 /// <param name="delay">The delay.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The repeatedly executing task.</returns>
 public static async Task Repeat(int repeats, Func <Task> task, TimeSpan delay, CancellationToken cancellationToken = default(CancellationToken))
 {
     await PeriodicTask.Repeat(repeats, async (CancellationToken ct) => await task(), delay, cancellationToken);
 }