@kuzulls
And I already said, what you suggested didn't fix the problem. :) I also tried the fix you gave for the reader program, and it actually did start working, and it also still works so that it makes the writer program work afterwards until usb cable is removed. But it doesn't solve the problem I need help with. The writer program (first piece of code) has to work without the reader program (second piece of code).
Inspired from the fixes, I also attempted having one waitForReadRead call with long timeout before trying to write there, but this didn't solve the problem which is, the device does not receive (or does not receive correctly) what I'm trying to send there unless I run the second piece of code first.
As for it being sync'd or async'd, it doesn't matter at this point. Purpose of this program / project at this stage is to get the connection to device to work for writing, it's okay if the program has to wait for the connection. Also it's worthwhile to mention (like I mentioned in OP) that this works in other environments than windows flawlessly, even with the "flawed" code I have now fixed (without seeing any changes in results really).