Ok. Let me try to explain what I need to do.
I 'm using CreateFile, ReadFile, WriteFile to send and receive packets over a communication channel (that is, using the device driver as a file). The problem I have is when I call ReadFile, it blocksthe program until a packet is received. So, I 'm using BeginInvoke in order to have this working on a separate thread and not block the main thread where the UI is working.
The problem is that, while ReadFile is waiting for a packet, I can not use WriteFile to send a packet (becausethe device driver is blocked by the ReadFile function). So I would try to kill the thread where ReadFile is running, so I cansend a packet, and then call the ReadFile again until a response is received.
Another option (and the best one)would be using ReadFile and WriteFile asynchronously, but I did not find information enought in order to make it.
Last chance, would be opening two handlers (one for receive and other for send), but the device driverdoes not accept this...
Any idea?
Regards;
Gus