示例#1
0
        /// <summary>
        /// Returns state after starting.
        /// </summary>
        /// <returns></returns>
        public TaskEventState Start()
        {
            if (!Current.Start())
            {   // if we cannot start, that means it is running or completed
                switch (Current.State)
                {
                case TaskEventState.TaskEventNew:
                    // illegal, should have been able to start from the Start method
                    Console.WriteLine("[ERROR] illegal, should have been able to start from the Start method");
                    break;

                case TaskEventState.TaskEventRunning:
                    // illegal
                    Console.WriteLine("[ERROR] illegal, should not try starting a task that was already running");
                    break;

                case TaskEventState.TaskEventComplete:
                    // make new, and start it
                    TaskEvents.Add(new TaskEvent());
                    Current.Start();
                    break;
                }
            }

            return(Current.State);
        }