コード例 #1
0
        private void Button_EndTask_Click(object sender, RoutedEventArgs e)
        {
            EndTask endTask = new EndTask();

            endTask.Show();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        protected override BehaviorTask createTask()
        {
            EndTask pTask = new EndTask();

            return(pTask);
        }