private void AddNewLandingWaiter(Plane plane) { LandingWaiters.Add(plane); simulatorService.InvokeLandingWaiter(plane); simulatorService.KeepPlaneWait(plane, LandingRunways, LandAfterWaiting); }
private void LandAfterWaiting(IStation station, Plane plane) { lock (station.Locker) { if (IsFirstWaiterPlane(station, plane)) //check if its thread first time. { simulatorService.RemoveWaiterFromStations(plane, LandingRunways.Cast <IStation>()); //remove plane from station waiters list. LandingRunwayStation rws = station as LandingRunwayStation; Land(plane, rws); LandingWaiters.Remove(plane); Task.Run(() => ContinueMovement(plane, rws)); //Run it in another thread so other threads will execute. } } }
//Plane arrive to the airport's airspace and request landing. public void NewLandingRequest(Plane plane) { if (!IsThereLandingWaiter()) { RunwayStation runway = GetRunwayToLand(); if (runway != null) { Land(plane, runway); return; } } LandingWaiters.Add(plane); notifyService.NewLandingWaiter(plane); //db update }