1

Bluetooth デバイスをスキャンするためのアルゴリズムを作成し、リストボックスに追加しました。このアルゴリズムをバックグラウンドで永続的に実行したいと考えています。しかし、私の Backgroundworker は正しく動作しません。私のUIも無反応です。

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
         toolStripStatusLabel1->Text="Active";
         toolStripProgressBar1->Value=100;
         backgroundWorker1->RunWorkerAsync();
     }

private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
         BluetoothFunction(); \\It tells me here is an Error
     }

void BluetoothFunction(){
        m_bt = BluetoothFindFirstRadio(&m_bt_find_radio, &m_radio);

        do{
            vector<wstring> vec;
            int m_device_id=0;
            int m_radio_id = 0;
            m_radio_id++;
            BluetoothGetRadioInfo(m_radio, &m_bt_info);

            m_search_params.hRadio = m_radio;
            ::ZeroMemory(&m_device_info, sizeof(BLUETOOTH_DEVICE_INFO));
            m_device_info.dwSize = sizeof(BLUETOOTH_DEVICE_INFO);
            m_bt_dev = BluetoothFindFirstDevice(&m_search_params, &m_device_info);

            do{
                wostringstream tmp;
                ++m_device_id;

                //Konvertiere Byte in String
                for (int i = 0; i < 6; i++) {
                  tmp << hex << m_device_info.Address.rgBytes [i];
                  if (i < 5)
                    tmp << L':';
                }                   

                //Verfügbarkeitsliste
                vec.push_back(tmp.str());

                listBox2->Items->Add(System::Runtime::InteropServices::Marshal::PtrToStringUni(IntPtr((void*) tmp.str().c_str())));

            }while(BluetoothFindNextDevice(m_bt_dev, &m_device_info));
            //searchId(vec, targetId); 
            BluetoothFindDeviceClose(m_bt_dev);

        } while(BluetoothFindNextRadio(&m_bt_find_radio, &m_radio));
        BluetoothFindRadioClose(m_bt);      
}

Bluetooth機能のパラメータが正しくないと思います。

誰かが私を助けることができれば、私はそれについてうれしいです.

よろしく

4

0 に答える 0