public void ApplicationDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { if (e != null) { FlightSimulatorModel.Get().ThrowNewError(e.Exception.Message); e.Handled = true; } }
private static Command ChooseCommand() { if (FlightSimulatorModel.Get().PriorityQueue.Count != 0) { return(FlightSimulatorModel.Get().PriorityQueue.Dequeue()); } else if (FlightSimulatorModel.Get().Queue.Count != 0) { return(FlightSimulatorModel.Get().Queue.Dequeue()); } else { return(null); } }
public override string getValue() { return(FlightSimulatorModel.Get().GetDataByKey(path())); }
public BaseNotify() { Model = FlightSimulatorModel.Get(); }
//create a tcp server with the default _port and _ip public static void CreateAndRunClient(NetworkStream stream) { try { if (stream == null) { return; } Byte[] data = null; // Get a client stream for reading and writing. // Stream stream = client.GetStream(); if (!_runClient) { FlightSimulatorModel.Get().ThrowNewError("Oops! you got runclient problem"); return; } while (_runClient) { // Translate the passed message into ASCII and store it as a Byte array. Command c = ChooseCommand(); if (c == null) { continue; } data = System.Text.Encoding.ASCII.GetBytes(c.execute()); // Send the message to the connected TcpServer. stream.Write(data, 0, data.Length); data = new Byte[256]; // String to store the response ASCII representation. String responseData = String.Empty; // Read the first batch of the TcpServer response bytes. Thread.Sleep(30); stream.ReadTimeout = 15000; Int32 bytes = stream.Read(data, 0, data.Length); responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes); responseData = responseData.Substring(0, responseData.Length - 1); FlightSimulatorModel.Get().UpdateValueMap(c.path(), responseData); } // Close everything stream.Close(); //MyTcpClient.client.Close(); } catch (IOException e) { if (stream != null) { stream.Close(); } //MyTcpClient.client.Close(); ThreadAlreadyRunning = false; FlightSimulatorModel.Get().ThrowNewError("Connection to the server was lost\r\nPlease insert IP and Port in the connection tab\r\n" + e.Message); _ip = String.Empty; _port = 0; } finally { _runClient = true; M.Set(); } }
public MainWindow() { InitializeComponent(); new Thread(FlightSimulatorModel.Get().InitRunBackground).Start(); }