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 }); }
void StopDDD() { m_ddd.Disconnect(); m_ddd = null; if (Properties.Settings.Default.RunDDDServer) { if (m_dddProcess != null) { m_dddProcess.Kill(); } m_dddProcess = null; } }
private bool DisconnectCurrentDDDSession(bool promptUser) { if (promptUser) { if (MessageBox.Show("A connection with the DDD currently exists, do you want to terminate this connection?", "Terminate DDD Connection", MessageBoxButtons.YesNo) == DialogResult.No) { return(false); } } if (_connection == null) { return(true); } lock (_connection) { try { _connection.Disconnect(); } finally { _connection = null; } } return(true); }