I have problems using the background event features of a device that connects via Bluetooth on Windows.
The C API that it comes with uses a rather uncommon approach:
The app has to register for receiving the events, but the API method does not expect any delegate to call then. Instead, it registers the thread as eligible and then one has to use another method, AwaitAsynchronousEvent (with an optional timeout value) that returns after the registered event occurred (or the timeout).
Xojo threads are no help in this matter: I can register during thread.run, but as there is only the AwaitMethod, the thread will not yield until the method finishes. So the GUI is still blocked.
I thought about using console helper apps, but then the API returns a DLL initialization error. Obviously only one program can access the API at one time. I had the same when I had supplier demo apps running and tried to access the device with my solution.
So a (yes, I know, unsupported) way would be to call the register and Await methods from a real background thread. There are API features like core dispatcher, and I think I even saw a “perform on background” method somewhere. Has this ever been done? Would this be a workable approach or doesnt it work at all?
Or are there other approaches to get a thread to yield when it is just waiting for one method result?