From: queisser on
I'm writing a C++ app using the Widcomm Bluetooth stack. Currently
running on XP but ultimately I want to also run my app on PocketPC.

My question: has anyone written a multithreaded app using the Widcomm
stack? My current approach is to have a class derived from CBtIf
create a thread that calls StartInquiry and StartDiscovery. The class
receives notifications in the OnDeviceResponded/OnInquiryComplete/
OnDiscoveryComplete overrides.

Once I've selected the devices to connect to I create one object
derived from CRfCommport per connection and call OpenClient. Each of
these objects has a thread that makes calls to Write and handles the
OnDataReceived override.

In the end I have one main thread for the GUI, one thread doing device
inquiry and discovery and one thread per connection doing Write and
OnDataReceived.

The OnXXX handlers are all threadsafe in the sense that they don't
contend with anything in the calling threads. I noticed that the OnXXX
handlers generally get called from a thread I didn't create,
presumably from the Widcomm stack.

Does anyone know if such an architecture should work with the Widcomm
stack. I've got it working with one connection so far but now I'm
getting weird Explorer hangs that appear to be related to the BT
stack.

Thanks,
Andrew