Example #1
0
 public void EnterStation(Plane plane)
 {
     if (IsWaitinglineEmpty && !isStationOccupied)
     {
         Task.Run(() =>
         {
             Wait(plane);
         });
     }
     else
     {
         WaitingLine.Enqueue(plane);
         ChangeInState?.Invoke(this, new StationChangedEventArgs(this.WaitingLine, plane, DateTime.Now, PlaneAction.EnterWaitingLine));
     }
 }
Example #2
0
        private void Wait(Plane plane)
        {
            lock (waitingLineLock)
            {
                isStationOccupied = true;
                base.CurrentPlane = plane;
                ChangeInState?.Invoke(this, new StationChangedEventArgs(this.WaitingLine, plane, DateTime.Now, PlaneAction.EnterStation));
                Thread.Sleep(base.WaitingTime);
                base.CurrentPlane = null;
            }

            isStationOccupied = false;
            ChangeInState?.Invoke(this, new StationChangedEventArgs(this.WaitingLine, plane, DateTime.Now, PlaneAction.LeaveStation));

            MoveToNextStation(plane);
        }