BTool.ComPortTreeForm.DisconnectDevice C# (CSharp) Method

DisconnectDevice() public method

public DisconnectDevice ( DeviceForm devForm ) : bool
devForm DeviceForm
return bool
        public bool DisconnectDevice(DeviceForm devForm)
        {
            bool flag = false;
            ConnectInfo connectInfo = devForm.disconnectInfo;
            if (devForm != null)
            {
                foreach (TreeNode treeNode in tvPorts.Nodes)
                {
                    if (((DeviceInfo)treeNode.Tag).ComPortInfo.ComPort == devForm.devInfo.ComPortInfo.ComPort)
                    {
                        string target = string.Format("Handle: 0x{0:X4}", connectInfo.Handle);
                        SharedObjects.Log.Write(Logging.MsgType.Debug, ComPortTreeForm.moduleName, "Disconnecting Device " + target);
                        if (flag = treeViewUtils.TreeNodeTextSearchAndDestroy(treeNode, target))
                            break;
                    }
                    if (flag)
                        break;
                }
            }
            else
                flag = false;
            return flag;
        }

Usage Example

コード例 #1
0
 private void DeviceDisconnectionNotify(object sender, EventArgs e)
 {
     if (InvokeRequired)
     {
         try
         {
             Invoke((Delegate) new DeviceDisconnectionNotifyDelegate(DeviceConnectionNotify), sender, e);
         }
         catch { }
     }
     else
     {
         m_mutex.WaitOne();
         DeviceForm devForm = sender as DeviceForm;
         if (devForm != null)
         {
             comPortTreeForm.DisconnectDevice(devForm);
         }
         m_mutex.ReleaseMutex();
     }
 }