public DeviceFormClose ( bool closeDevice ) : void | ||
closeDevice | bool | |
return | void |
public void DeviceFormClose(bool closeDevice)
{
if (closeDevice && !formClosing)
{
formClosing = true;
CloseActiveDevice(this, null);
}
threadMgr.PauseThreads();
threadMgr.WaitForPause();
threadMgr.ClearQueues();
commMgr.ClosePort();
if (processRxProc != null)
while (processRxProc.IsAlive)
;
msgLogForm.ResetMsgNumber();
threadMgr.ExitThreads();
SaveUserSettings();
}
private void AddDeviceForm() { if (InvokeRequired) { try { Invoke((Delegate)new AddDeviceFormDelegate(AddDeviceForm)); } catch { } } else { m_mutex.WaitOne(); DeviceForm deviceForm = new DeviceForm(); if (deviceForm == null) return; deviceForm.BDAddressNotify += new EventHandler(DeviceBDAddressNotify); deviceForm.ConnectionNotify += new EventHandler(DeviceConnectionNotify); deviceForm.DisconnectionNotify += new EventHandler(DeviceDisconnectionNotify); deviceForm.ChangeActiveRoot += new EventHandler(DeviceChangeActiveRoot); deviceForm.CloseActiveDevice += new EventHandler(DeviceCloseActiveDevice); if (deviceForm.DeviceFormInit()) { deviceForm.TopLevel = false; deviceForm.Parent = plDevice; deviceForm.Dock = DockStyle.Fill; foreach (Control control in plDevice.Controls) { if (control.GetType().BaseType == typeof(Form)) { Form form = (Form)control; if (form.Visible) { form.Hide(); break; } } } deviceForm.Show(); AddToTreeDeviceInfo(deviceForm.devInfo, deviceForm); comPortTreeForm.ClearSelectedNode(); deviceForm.SendGAPDeviceInit(); } else deviceForm.DeviceFormClose(false); m_mutex.ReleaseMutex(); } }