Hi,
I am experiencing a very strange incompatibility with WaitForInputHandle() and a Delphi app that communicates with a
USB device.
Application A starts application B using CreateProcess() followed by WaitForInputIdle(). The problem is that WaitForInputIdle() blocks indefinetely or until application B quits. Application B runs fine w/o any problems. The problem exists only with application B. If I exchange application B for "notepad.exe" or any other application written in Delphi things work fine.
The unusual thing about application B is that it communicates with a USB device on startup (initiated in FormCreate()). The USB device communications class uses asynchronous I/O, and receiving data from the device is done in a separate read thread. On reception the read thread uses synchronize() to pass data to the main (VCL) thread. On startup the device immediately sends a few bytes, and it seems to be the use of Synchronize() in the few mS after startup that somehow interferes with WaitForInputIdle() in the other application. If I ignore reception in the first 100 mS or so, or place a delay of 100 mS (with Application.ProcessMessages being called regurarly) in FormCreate before connecting to the device the problem disappears. I need to understand why synchronize()is interfering with WaitForInputHandle() and why waiting 100 mS helps.
Thanks for any help :-)
/Rolf