Ejemplo n.º 1
0
 //Must call leave after train exits registered rail
 public void Register(Train train)
 {
     lock (_signalLock)
     {
         if (CurrentTrain == null)
         {
             CurrentTrain = train;
             CurrentTrain.Signal(this);
         }
         else
         {
             _trains.Enqueue(train);
         }
     }
 }
Ejemplo n.º 2
0
        //Signals that no train is currently on rail
        public void Leave(Train train)
        {
            lock (_signalLock)
            {
                if (CurrentTrain == null || train.Guid != CurrentTrain.Guid)
                {
                    return;
                }

                if (_trains.Count > 0)
                {
                    CurrentTrain = _trains.Dequeue();
                    CurrentTrain.Signal(this);
                }
                else
                {
                    CurrentTrain = null;
                }
            }
        }