private void CancelAllThreads()
        {
            try
            {
                if (_connectThread != null)
                {
                    _connectThread.Cancel();
                    _connectThread = null;
                }

                if (_transferOutThread != null)
                {
                    _transferOutThread.Cancel();
                    _transferOutThread = null;
                }

                if (_transferInThread != null)
                {
                    _transferInThread.Cancel();
                    _transferInThread = null;
                }

                if (_acceptThread != null)
                {
                    _acceptThread.Cancel();
                    _acceptThread = null;
                }

                RemoteDevice = null;
            }
            catch (Exception e)
            {
                SAMLog.Error("ABTA::CAT", e);
            }
        }
        public void ThreadMessage_Connected(BluetoothSocket socket, BluetoothDevice device)
        {
            CancelAllThreads();

            try
            {
                _transferOutThread = new BTTransferSendThread(socket, this);
                _transferInThread  = new BTTransferRecieveThread(socket, this);

                _transferOutThread.Start();
                _transferInThread.Start();
            }
            catch (Exception e)
            {
                SAMLog.Error("ABTA::CantCreateConnectedThread", e);
                State = BluetoothAdapterState.Error;
                CancelAllThreads();
                return;
            }

            RemoteDevice = new BTDeviceWrapper(device);

            State = BluetoothAdapterState.Connected;
        }