I would think this is ok, and you can decide how often you poll, just don't do it all the time. You may use a flag for poll-only mode which reduces the polling period and disables the FileSystemWatcher, which would make it kind of universal. You could even call the same callback.
J
jmhamm
@jmhamm
Posts
-
FileSystemWatcher vs. Own file system polling -
Enumerators and locks.Will do, thanks!
-
FileSystemWatcher vs. Own file system pollingYou could create a thread, spins in a loop and reinitializes the FileSystemWatcher from time to time using Thread.Sleep in between. As FileSystemWatcher uses events this would effectively create a mix of polling and signaling.
-
Enumerators and locks.Does anyone know how to best lock access to the object during enumeration? Eg, is it a bad/good idea to use a Monitor.Enter in the constructor and a Monitor.Exit in the dispose function? I know, I could put a lock around, but I really need this to happen automatically. Cheers.