public async void TakeFlight(FlightPosition flight) { //Sending information to client, that the current line take new craft await _airportHub.Clients.All.SendAsync("transferdata", new { Number, State = true, Craft = flight.Craft.Number, flight.Craft.Direction }); lock (this) { //var data = $"Line {Number} start taking new flight {flight.Craft.Number} with direction {flight.Craft.Direction}"; //logger.Info(data); //Taking craft from previous line in case, that it was on waiting mode if (flight.PreviousLine != null) { //logger.Info($"Start moving flight {flight.Craft.Number} from previos line {flight.PreviousLine.Number}"); flight.PreviousLine.Move(); } if (Current == null) { //logger.Info($"Line {Number} start place new flight {flight.Craft.Number} with direction {flight.Craft.Direction} and set servicing time"); Busy = true; Current = flight.Craft; Downtime = Helper.GetRandom(Settings.MinServiceTime, Settings.MaxServiceTime); TimerCallback timeCB = new TimerCallback(StartLetOutFlight); Handling = new Timer(timeCB, null, Downtime, -1); //logger.Info($"Line {Number} set {flight.Craft.Number} for service time {Downtime}"); CurrentMove = new FlightMove { Number = Current.Number, LineNumber = Number, Start = DateTime.Now }; if (flight.OldPosition == -1) { //Add snapshot for new arrival or departure _repo.AddLinesSnapshot(new LineDB { IsBusy = true, Number = Number, Direction = (Current.Direction == 1 ? "arrive" : "depart") }, -1); } else { //Add snapshot for standart move _repo.AddLinesSnapshot(new LineDB { IsBusy = true, Number = Number, Direction = (Current.Direction == 1 ? "arrive" : "depart") }, flight.OldPosition); } } } }