Description
I create my input and output connections in the usual way.
For this particular piece of code, I don't hold on to the connections for the lifetime of my application. Instead, I acquire them, do some code, and then release them. It's for iterating the list of preset instruments in my keyboard on application startup, and caching them.
Immediately after I have created those connections, after checking for connection errors, I send a message via the output connection (it happens to be a SysEx identify message).
Either my MIDI device does not receive that message, or my device responds to that message before the callback is ready. Whichever case, this first message is seemingly lost, the callback never receives it.
I have worked around this by doing a sleep for 50-100ms before sending the message, and that does work.
However, I expected that since I have a valid connection instance, by the time I have that instance everything should already be set up and ready to go.
If the short sleep is the answer, then fair enough, but is there no more deterministic way to make this work?