protected override void OnConnectionClosed(MsgConnectionClosed msg) { using (var a = new FileStream("Test.txt", FileMode.Append, FileAccess.Write)) using (var b = new StreamWriter(a)) { b.WriteLine($"{DateTime.Now.TimeOfDay}: OnConnectionClosed Called {msg.CarId}"); } var competitor = Competitors.FirstOrDefault(comp => comp.ConnectionId == msg.CarId && comp.DriverGuid == msg.DriverGuid); Competitors.Remove(competitor); competitor.IsConnected = false; ApiWrapperNet4.Post <Competitor>("competitor/disconnectCompetitor", competitor); }