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 StartWaiting()
        {
            CancelAllThreads();

            EnsureDiscoverable(120);

            try
            {
                _acceptThread = new BTAcceptThread(this);
                _acceptThread.Start();
            }
            catch (Exception e)
            {
                SAMLog.Error("ABTA::CantCreateAcceptThread", e);
                State = BluetoothAdapterState.Error;
                CancelAllThreads();
                return;
            }

            State = BluetoothAdapterState.Listen;
        }