My .NET (PC-based) application has an array of Bluetooth devices attached. I'm trying to handle the situation where one of the devices walks away or is powered down.
The Discovery.OnDeviceLost handler is very slow and unresponsive. It often misses the fact that I've disconnected:
wclBluetoothDiscovery.OnDeviceLost += new wcl.wclBluetoothDiscoveryDeviceEventHandler(OnBluetoothDeviceLost);
private void OnBluetoothDeviceLost(object sender, wcl.wclBluetoothDiscoveryDeviceEventArgs e)
{
// use "e.Device.Address" to determine which device was lost
}
The wclsyncClient.OnConnect handler which conveniently provides the device address in the argument.
However, the wclSyncClient.OnDisconnect handler doesn't provide the address of the device that was lost.
syncClients = new wclSyncClient[gageArray.Length];
comboBoxGageName.Items.Clear();
for (int i = 0; i < gageArray.Length; i++)
{
syncClients = new wclSyncClient();
syncClients.OnDisconnect += new System.EventHandler(OnBluetoothDisconnect);
syncClients.OnConnect += new wcl.wclConnectEventHandler(OnBluetoothConnect);
comboBoxGageName.Items.Add(gageArray.strUserName);
}
private void OnBluetoothDisconnect(object sender, EventArgs e)
{
// how do I know which device was lost?
// the EventArgs don't tell me which device was lost !!!
}
Questions:
How should I immediately detect and handle the situation when one of my devices walks away or is powered down? The "OnDeviceLost" is very slow as is the "InRange". The OnDisconnect seems to be a bit better (although pretty slow) - however, I cannot determine which of the devices in my array was lost.
Thanks,
- Mark