Open dkorpel opened 5 years ago
So it seems the double messages are just a quirk of the Windows filesystem: https://stackoverflow.com/questions/14036449/c-winapi-readdirectorychangesw-receiving-double-notifications https://stackoverflow.com/questions/9902758/filesystemwatcher-double-entries
The empty array between the double messages seems to have to do with the queued
variable switching between true and false every time you call getEvents
. When queued
is true, ReadDirectoryChangesW is called and queued
is set to false. When queued
is false, GetOverlappedResult is called, actual messages are gathered, and queued
is set to true. What is the purpose behind the queued variable?
uh I can't really remember what I wrote there and can't really read what it was supposed to do either
I tried out watching a folder named "test" in Windows 10:
I noticed that I receive more messages than needed:
Even if I change the sleep time, it's always first an empty event array and then an array with redundant messages. I don't know if this is just how the Windows API works or if some extra modifications are being done under the hood, but it's weird how they show up only after calling getEvents() twice more.