Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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;
        }