I'm trying to connect through the application I'm making as a client to my phone for testing purposes, but I'm missing something. After pairing the devices, the program should open a new thread on which it runs client.BeginConnect, but it only gets as far as "Starting connect thread...".
BluetoothDeviceInfo deviceInfo;
private void listBox1_DoubleClick(object sender, EventArgs e)
{
deviceInfo = devices.ElementAt(listBox1.SelectedIndex);
updateUI(deviceInfo.DeviceName + " was selected. Attempting to connect.");
if (pairDevice())
{
updateUI("Device paired.");
updateUI("Starting connect thread...");
Thread bluetoothClientThread = new Thread(new ThreadStart(ClientConnectThread));
}
else
{
updateUI("Pairing failed.");
}
}
private void ClientConnectThread()
{
updateUI("Attempting connect.");
client.BeginConnect(deviceInfo.DeviceAddress, BluetoothService.SerialPort, new AsyncCallback(BluetoothClientConnectCallback), client);
}
I tried reusing a thread I used for scanning for devices previously and pasted the BeginConnect there, but that just makes the program crash. I'm unsure of what error it might show, because I'm programming it on my PC, but can only test the program on another laptop using the .exe file.