diff --git a/source/eventcore/drivers/winapi/core.d b/source/eventcore/drivers/winapi/core.d index 321130f..c33e85a 100644 --- a/source/eventcore/drivers/winapi/core.d +++ b/source/eventcore/drivers/winapi/core.d @@ -170,8 +170,10 @@ final class WinAPIEventDriverCore : EventDriverCore { auto ret = () @trusted { return MsgWaitForMultipleObjectsEx(cast(DWORD)m_registeredEvents.length, m_registeredEvents.ptr, timeout_msecs, QS_ALLEVENTS, MWMO_ALERTABLE|MWMO_INPUTAVAILABLE); } (); - foreach (evt; m_ioEvents.consume) + while (!m_ioEvents.empty) { + auto evt = m_ioEvents.consumeOne(); evt.process(evt.error, evt.bytesTransferred, evt.overlapped); + } if (ret == WAIT_IO_COMPLETION) got_event = true; else if (ret >= WAIT_OBJECT_0 && ret < WAIT_OBJECT_0 + m_registeredEvents.length) { diff --git a/source/eventcore/drivers/winapi/files.d b/source/eventcore/drivers/winapi/files.d index d69a3c1..5dac5f8 100644 --- a/source/eventcore/drivers/winapi/files.d +++ b/source/eventcore/drivers/winapi/files.d @@ -204,6 +204,7 @@ final class WinAPIEventDriverFiles : EventDriverFiles { { FileFD id = cast(FileFD)cast(size_t)overlapped.hEvent; auto handle = idToHandle(id); + if (handle == INVALID_HANDLE_VALUE) return; static if (RO) auto slot = () @trusted { return &overlapped.driver.m_handles[handle].file.write; } (); else