Example #1
0
 public override void Dispose()
 {
     if (_device != null)
     {
         _device.Dispose();
         _device = null;
     }
 }
Example #2
0
        private bool DisconnectFromSelectedDevice()
        {
            bool fDisconnected = (m_device == null);

            if (m_device != null)
            {
                if (Interlocked.Decrement(ref m_deviceRefCount) <= 0)
                {
                    this.Invoke((MethodInvoker) delegate
                    {
                        connectToolStripMenuItem.Checked = false;
                        comboBoxDevice.Enabled           = true;
                        comboBoxTransport.Enabled        = true;
                        connectToolStripMenuItem.Enabled = true;
                    });

                    fDisconnected = true;

                    m_device.OnDebugText -= new EventHandler <DebugOutputEventArgs>(OnDbgTxt);
                    m_device.Dispose();
                    m_device = null;
                }
            }
            else
            {
                this.Invoke((MethodInvoker) delegate
                {
                    connectToolStripMenuItem.Checked = false;
                    comboBoxDevice.Enabled           = true;
                    comboBoxTransport.Enabled        = true;
                    connectToolStripMenuItem.Enabled = true;
                });
            }

            return(fDisconnected);
        }
Example #3
0
    public bool Disconnect()
    {
        bool fDisconnected = (m_device == null);

        if (m_device != null)
        {
            if (Interlocked.Decrement(ref m_devRefCount) <= 0)
            {
                fDisconnected = true;

                m_device.OnDebugText -= new EventHandler <DebugOutputEventArgs>(OnDbgTxt);
                m_device.Dispose();
                m_device = null;
            }
        }
        else
        {
        }

        return(fDisconnected);
    }