Пример #1
0
 private void Phase_Done(object sender, EventArgs e)
 {
     if (phaseQueue.Count != 0)
     {
         CurrentPhase = phaseQueue.Dequeue();
         CurrentPhase.Run();
     }
 }
Пример #2
0
 private void Phase_Done(object sender, EventArgs e)
 {
     //execute the next phase in the Queue
     if (phaseQueue.Count != 0)
     {
         CurrentPhase = phaseQueue.Dequeue();
         CurrentPhase.Run();
     }
 }
Пример #3
0
 private void Phase_Done(object sender, EventArgs e)
 {
     //execute the next phase in the Queue and inform the Events
     if (PhaseQueue.Count != 0)
     {
         CurrentPhase          = PhaseQueue.Dequeue();
         CurrentPhase.Done    += Phase_Done;
         CurrentPhase.Elapsed += Phase_Elapsed;
         CurrentPhase.Run();
     }
     OnPhaseChanged();
 }
Пример #4
0
        private void StopButton_Click(object sender, EventArgs e)
        {
            //Add the phases to a Queue with the time duration
            var phaseQueue = new Queue <TrafficPhase>();

            phaseQueue.Enqueue(new TrafficPhase(PhaseType.Attention, 3));
            phaseQueue.Enqueue(new TrafficPhase(PhaseType.Stop, 7));
            phaseQueue.Enqueue(new TrafficPhase(PhaseType.Prepare, 2));

            CurrentPhase.Run();

            //execute the Queue elements statrs from the first phase
            while (phaseQueue.Count > 0)
            {
                CurrentPhase = phaseQueue.Dequeue();
                CurrentPhase.Run();
            }

            //set the Go phase as the last phase
            CurrentPhase = new TrafficPhase(PhaseType.Go, 7);
        }