void ConnectClicked() { if (flightBoardModel.IsConnect()) { flightBoardModel.Stop(); Commands.Instance.Init(); System.Threading.Thread.Sleep(1000); } new Thread(delegate() { Commands.Instance.ServerConnect(ApplicationSettingsModel.Instance.FlightServerIP, ApplicationSettingsModel.Instance.FlightCommandPort); }).Start(); flightBoardModel.Connect(ApplicationSettingsModel.Instance.FlightServerIP, ApplicationSettingsModel.Instance.FlightInfoPort); }
private void OnDisconnectClick() { stop = true; //gracefully closing the connection and the info channel thread model.Stop(); if (t.IsAlive) { if (t != Thread.CurrentThread) { t.Join(); } } Debug.WriteLine("The thread of info channel has successfully finished"); model.Disconnect(); Debug.WriteLine("Successfully disconnected both channels"); }