Nonblocking FileWrite problem

2005-03-16 04:36:19 AM
Dear Newsgroup,
I'm using a serial port to read and write data from/to it. I need to
configure it as non-blocking because killing the reader thread caused
My problem is, I've got the following code to send data:
while FileWrite(SerFileHandle, Buffer, Count) = -1 do begin
And, of course, it's causing a high processor load.
When I add a Sleep(1); inside the begin...end, it's to slow.
My question to you: Is there a better solution to send data (i.e. get
informed when the data was sent), while still sticking to the
non-blocking solution?