private void CONNECTION_STATUS_CALLBACK(short wServiceClass, IntPtr lpBdAddr, NativeMethods.CONNECTION_STATUS ucStatus, int dwConnetionHandle) { BluetoothConnection connection; if (!lookupConnections.TryGetValue(dwConnetionHandle, out connection)) { return; } BluetoothConnectionStatus newStatus = BluetoothConnectionStatus.Connected; if (ucStatus == NativeMethods.CONNECTION_STATUS.STATUS_INCOMING_DISCONNECT || ucStatus == NativeMethods.CONNECTION_STATUS.STATUS_OUTGOING_DISCONNECT) { newStatus = BluetoothConnectionStatus.Disconnected; } connection.Status = newStatus; lookupConnections.Remove(connection.ConnectionHandle); connections.Remove(connection); if (newStatus == BluetoothConnectionStatus.Disconnected) { OnConnectionClosed(new BluetoothConnectionEventArgs(connection)); } }
private static void static_CONNECTION_STATUS_CALLBACK(short wServiceClass, IntPtr lpBdAddr, NativeMethods.CONNECTION_STATUS ucStatus, int dwConnetionHandle) { Instance.CONNECTION_STATUS_CALLBACK(wServiceClass, lpBdAddr, ucStatus, dwConnetionHandle); }