private void Button_EndTask_Click(object sender, RoutedEventArgs e) { EndTask endTask = new EndTask(); endTask.Show(); }
public static Task timerForGame(int waitPrRunSeconds, int secondsBeforeEnd, StartTask messageOnCountdown, EndTask timeRunOutTask) { Task task = new Task(() => { CancellationToken token = tokenSource.Token; for (int i = secondsBeforeEnd; i <= secondsBeforeEnd && i > -1 && !token.IsCancellationRequested; i--) { if (i < secondsBeforeEnd && i > 0) { Task.Delay(waitPrRunSeconds * 1000).Wait(); if (!token.IsCancellationRequested) { messageOnCountdown(); Console.WriteLine(i + "\n"); } } else if (i <= 0) { Task.Delay(waitPrRunSeconds * 1000).Wait(); timeRunOutTask(); } } }); task.Start(); return(task); }
protected override BehaviorTask createTask() { EndTask pTask = new EndTask(); return(pTask); }