Tomer Gabel's annoying spot on the 'net RSS 2.0
# Wednesday, August 17, 2005
I was implementing a watchdog system over a certain system's XML configuration repository using System.IO.FileSystemWatcher. Annoyingly, changes to the file (such as saving it with Notepad) would often result in the change event being fired twice. The system is designed so that whenever the file is changed, it is reloaded and several parts of the system are suspended (via thread synchronization) while the information is being re-cached. This in itself wouldn't be a problem since changes to the XML files are manual and rare, the XML schemas and serialization metadata are already cached etc. so the reloading operation shouldn't take more than 100-200ms (and the lock itself is only obtained at the very end of said process) - however there is a drain on CPU time and memory resources which I certainly wouldn't want doubled.

While it seems I wasn't the only one to encounter this behaviour, I've yet to see a proper solution to it; in the meanwhile I settled for a small hack where an update to the XML file are only processed if n seconds (2 in my case) have elapsed since the last update. Does anyone know of a cleaner way to solve this?

Wednesday, August 17, 2005 2:00:41 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [3] -
Development
Tuesday, August 23, 2005 10:38:41 AM (Jerusalem Standard Time, UTC+02:00)
Tomer,

It's a known problem, we had it at work too with the configurator.

I think that my conclusion then was that the problem is not with the watcher, it's with notepad. it actually changes the file twice.
when I used other editors the problem didn't happen as far as I remember,
but as you said, since configuration is rarely changing, I didn't mind that.

Eli.
Wednesday, August 24, 2005 4:56:34 PM (Jerusalem Standard Time, UTC+02:00)
FileSystemWatcher is problematic in its own.

My exprience with it indicates that it doesn't work well when you blown a full load of files afront of it.

The way it handles a situation like this is skipping files, meaning it only reports for some of the files due process.

You probably understand the frustration and anger levels I was feeling towards that Class at that time. :)
Wednesday, August 24, 2005 9:06:42 PM (Jerusalem Standard Time, UTC+02:00)
What you are describing is well documented behaviour. It has to do with the buffer size for the FSW, which is configurable - however you have to be careful because it is allocated from the nonpaged memory pool (meaning it cannot be swapped out and is always part of your working set).
OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Live Comment Preview
Me!
Send mail to the author(s) Be afraid.
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
All Content © 2012, Tomer Gabel
Based on the Business theme for dasBlog created by Christoph De Baene (delarou)