public void StartConnect(string host, string shareName, int port, ConnectCompleteDelegate callback) { if (_dddConnection != null) { if (_dddConnection.IsConnected()) { _dddConnection.Disconnect(); } } _simModelPath = String.Format(@"\\{0}\{1}\SimulationModel.xml", host, shareName); SimulationModelReader rdr = new SimulationModelReader(); _simModel = rdr.readModel(_simModelPath); _dddConnection.DDDClientPath = String.Format(@"\\{0}\{1}", host, shareName); _connectCompleteCallback = callback; //bool result = false;// = _dddConnection.ConnectToServer(host, port); //_connectRunning = true; //while (true) //{ // lock (_connectionLock) // { // if (!_connectRunning) // { // break; // } // } // Thread.Sleep(1000); //} _connectThread = new Thread(new ParameterizedThreadStart(T_Connect)); _connectThread.Start(new object[] { host, port }); }
private void DDDLoop() { bool isConnected = true; lock (_connection) {//lock so you can disconnect on the main thread isConnected = _connection.IsConnected(); } while (isConnected) { _connection.ProcessEvents(); Thread.Sleep(500); try { lock (_connection) { isConnected = _connection.IsConnected(); } } catch (Exception ex) { isConnected = false; } } //MessageBox.Show("DDD Loop Terminated"); }
private void updateTimer_Tick(object sender, EventArgs e) { if (m_ddd != null) { if (!m_ddd.IsConnected()) { MessageBox.Show("Lost connection to the DDD Server", "DDD Connection Error"); Environment.Exit(0); } m_ddd.ProcessEvents(); timeTextBox.Text = m_ddd.DDDTimeString; if (m_currentRun != null) { if (m_ddd.DDDTimeInt >= m_currentRunFinishTime) { FinishCurrentRun(); } } } else { timeTextBox.Text = "N/A"; } }
private void okButton_Click(object sender, EventArgs e) { if (m_serverConnection.IsConnected()) { MessageBox.Show("Already connected!"); DialogResult = DialogResult.OK; } if (!m_serverConnection.ConnectToServer(serverHostnameTextBox.Text, Int32.Parse(serverPortNumberTextBox.Text))) { MessageBox.Show(String.Format("Unable to connect to {0}:{1}", serverHostnameTextBox.Text, serverPortNumberTextBox.Text)); return; } m_serverConnection.DDDClientPath = String.Format("\\\\{0}\\DDDClient", serverHostnameTextBox.Text); //String path = String.Format("\\\\{0}\\DDDClient\\SimulationModel.xml", serverHostnameTextBox.Text); if (!m_serverConnection.ReadSimModel()) { MessageBox.Show(String.Format("Unable to read sim model")); return; } ServerHostname = serverHostnameTextBox.Text; DialogResult = DialogResult.OK; //LoginDialog loginDialog = new LoginDialog(serverConnection); //Hide(); //loginDialog.Show(); }