Das habe ich auch so.
Mein Thread:
Delphi-Quellcode:
while not Terminated do
begin
HandleBuffer[0] := rOverlapped.hEvent;
HandleBuffer[1] := wOverlapped.hEvent;
Return := MsgWaitForMultipleObjects (Handles, HandleBuffer, False,
2000, QS_ALLINPUT);
if Terminated then exit;
Case Return of
WAIT_OBJECT_0 : begin
ReadFile (MyHandle, ReceiveBuffer, 1024, ReceivedBytes, Nil); //<- ReceivedBytes = 0
ReceivedBytes := rOverlapped.InternalHigh; //<- ReceivedBytes = 4
//ReceiveBuffer ist leer
ResetEvent(rOverlapped.hEvent);
rOverlapped.Offset := 0;
rOverlapped.OffsetHigh := 0;
if ReceivedBytes > 0 then
begin
...
WAIT_OBJECT_0+1 ist fürs Schreiben.
Abfrage der Schnittstelle:
Delphi-Quellcode:
rOverlapped.Offset := 0;
rOverlapped.OffsetHigh := 0;
TmpMask := EV_RXFLAG;
WaitCommEvent(MyHandle, TmpMask, @rOverlapped);
Sollte dem von dir entsprechen...
Zeiten sind beim Init entsprechend auf 0 oder MaxDWord