Recent

Author Topic: [SOLVED] How to cleanup ReadDirectoryChangesW operations properly?  (Read 10483 times)

d7_2_laz

  • Full Member
  • ***
  • Posts: 198
Re: [SOLVED] How to cleanup ReadDirectoryChangesW operations properly?
« Reply #15 on: May 27, 2021, 01:06:52 pm »
Hello ASerge, i did try your example with great interest (such examples are so helpful for users!) and try to summarize my picture what's equal and what's different.
I think the core functionality of monitoring is similar, but simply the method of push back of change info differs a bit.

Your's passes the change info, after GetOverlappedResult, directly back to the Gui (UpdateLog) which is fully appropriate and sufficient for most use cases. Such examples are a valuable source to learn!
Mine is, additionally, using WaitForMultipleObjects and, after the GetOverlappedResult, it passes back the info to the Gui in a deferred way.
By:  PostMessage to the parent control (TFldrControl), which stores the data (BufferTheDataViaNotify) in a StringList (where the strings do contain the names, and the objects keep an info about the change type, e.g. "rename"). Then, controlled by a timer, those data are pushed back to the Gui.
Honestly, in a retrospective i do not remember why a thread should be needed for that (should be proven by practice).
If i could do it from the scratch, i would try to use your example as base and extend it a bit for to use buffering (then the using app can decide how to process such changes ...  for instance rebuild a list completely or maintain items individually), but without threads.Shouldn't be a big thing-

ASerge

  • Hero Member
  • *****
  • Posts: 1868
Re: [SOLVED] How to cleanup ReadDirectoryChangesW operations properly?
« Reply #16 on: May 27, 2021, 03:23:43 pm »
The method without threads also has its drawbacks. The message queue of the main thread is used to wait for the event. But if you call up some system dialog box, such as opening a file, then it will have its own queue. This means that the event will not be available until the dialog closes.

d7_2_laz

  • Full Member
  • ***
  • Posts: 198
Re: [SOLVED] How to cleanup ReadDirectoryChangesW operations properly?
« Reply #17 on: May 27, 2021, 07:40:23 pm »
... so if one relies on that the monitor is independent from possible blocking effects from user interactions,
then the thread approach might be a more desired option. The specific use case each needs to be considered, i think.
Thanks a lot for all your feedbacks ASerge!  :)

 

TinyPortal © 2005-2018