private async void WaitTaskAsync(SchedulerTask task, CancellationToken Cancel) { var task_time = task.Time; //извлечение времени var delta = task_time.Subtract(DateTime.Now); //найти сколько спать await Task.Delay(delta, Cancel).ConfigureAwait(false); //поспать await ExecuteTask(task, Cancel); //разослать почту _TasksStore.Remove(task.Id); //удалить задачу await StartAsync(); }
private async void WaitTaskAsync(SchedulerTask task, CancellationToken Cancel) { var task_time = task.Time; var delta = task_time.Subtract(DateTime.Now); await Task.Delay(delta, Cancel).ConfigureAwait(false); await ExecuteTask(task, Cancel); _TasksStore.Remove(task.Id); await StartAsync(); }
private async void WaitTaskAsync(SchedulerTask task, CancellationToken Cancel) { Cancel.ThrowIfCancellationRequested(); var task_time = task.Time; var delta = task_time.Subtract(DateTime.Now); if (delta.TotalSeconds > 0) { await Task.Delay(delta, Cancel).ConfigureAwait(false); } Cancel.ThrowIfCancellationRequested(); await ExecuteTask(task, Cancel); _TasksStore.Remove(task.Id); await Task.Run(Start, Cancel); }