473,811 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileSystemWatch er is unreliable

We have noticed that the FileSystemWatch er is not reliable. It is not easily
repeatable but sometime it fails to catch file system changes. When it gets
into this state it doesn't recover unless a reboot is done.

The problem is only seen when multiple files are copied to the system in
quick succession. Once the watcher misses a file *any* subsequent incoming
file isn't seen.

I found this comment on the http://www.experts-exchange.com site:

I also include a "directory sweep" that periodically checks the directories
that the filewatchers are monitoring to make certain no files have been
missed and to detect files that may have been created while the filewatchers
were not running. remember if a file is placed in a directory and the file
watcher is started afterwords - the File_Created event will not fire.

It seems that others have experienced this bugger.

Any other ideas or comments?

-jeff
Feb 23 '06 #1
2 13068
> We have noticed that the FileSystemWatch er is not reliable.

I think FileSystemWatch er is implemented using win32 api
ReadDirectoryCh angesW. If that is true, then the documented limitations of
ReadDirectoryCh angesW will convey to FileSystemWatch er. One such limitation
is associated with many updates in a short period of time.

If all of the above is true (sorry, I really don't know), then a belt and
suspenders design is to use a timer to trigger an examination everything in
the directory of interest, in other words, polling, and you could be smart
about the polling interval. During periods of heavy file activity, decrease
the interval. During periods of file inactivity, increase the interval. A
FileSystemWatch er could set the interval to 'immediate' when it sees
something. In this way, you would process quickly when the watcher sees
something, but you will always get around to it if the watcher fails.

In this kind of design, I would use the FileSystemWatch er only as a trigger
to look at all files - I would not use it to trigger specific files. I think
if you limit the watcher to trigger only, its reliability will improve. And
you could periodically reinstantiate the watcher object. If you really have
a failure mode that requires a reboot, then I wouldn't use it at all, but my
guess is that reinstantiating it fixes whatever failures you may be
encountering.

In programming, as in boxing, protect yourself at all times. Good luck.
Feb 24 '06 #2
Arnie wrote:
We have noticed that the FileSystemWatch er is not reliable. It is not easily
repeatable but sometime it fails to catch file system changes. When it gets
into this state it doesn't recover unless a reboot is done.

The problem is only seen when multiple files are copied to the system in
quick succession. Once the watcher misses a file *any* subsequent incoming
file isn't seen.

I found this comment on the http://www.experts-exchange.com site:

I also include a "directory sweep" that periodically checks the directories
that the filewatchers are monitoring to make certain no files have been
missed and to detect files that may have been created while the filewatchers
were not running. remember if a file is placed in a directory and the file
watcher is started afterwords - the File_Created event will not fire.

It seems that others have experienced this bugger.

Any other ideas or comments?


I wrote a service that monitored an "inbox" folder and, when a file write
occured, moved the file to a work folder for processing. After processing, it
handles the next write that might have occured, and so on.

The watcher event triggered the moment the write began, meaning that my process
had to wait until the file finished. While the thread was waiting, I might have
several more files arrive; if I wait too long, the events timeout from the queue
and the files are not processed, leaving orphaned files that weren't processed.
I tried multi-threading, but that introduced other problems (such as a shared
printer object) that I was unable to solve to my satisfaction.

In the end, I threw away the FileSystemWatch er and recreated the previous, non
..NET method I used successfully for several years: sleep the main thread for a
minute, have it process up to five files from the inbox, sleep for 60 seconds,
repeat.
--
Gregory Gadow
Feb 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4714
by: James R. Saker Jr. | last post by:
I see per pydoc that Queue.Queue()'s .qsize is allegedly unreliable: | qsize(self) | Return the approximate size of the queue (not reliable!). Any thoughts on why this is unreliable (and more curiously, why it would be put in there as an unreliable function?) Rather than roll my own threaded fifo class, it would seem prudent to use Python's built-in Queue but the warning signs on a rather necessary function seem curious.
1
3338
by: Troy Murphy | last post by:
How do I prevent the FileSystemWatcher event to keep firing while the file is being created? When copying a file to the watched folder, the event fires a dozen or more times! Also, the documentation states that if more than one file is copied to the folder at the same time, a cache will queue them up for processing, but when I drop 3 files into this folder, only the 1st (sometimes the first two) cause the event to fire. Thanks, Troy
7
4126
by: Allen Anderson | last post by:
I'm trying to figure out a way to catch when a file has been written to a directory. I currently have it where I can catch when the file begins writing, but this isn't helpful as I need to know when its done. Does anyone know the right combination of flags to use to catch when the file has been written and closed? (here is my current code). // member variable FileSystemWatcher watcher = new FileSystemWatcher();
2
2232
by: Jet Leung | last post by:
Hi all, I had made a program to watching files in my directory. I had used a instance of FileSystemWatcher to do my work.And I had add some events of the FileSystemWatcher , for example onChange, onRename and so on. And I had made this program as a windows service.As I know, if I delete a file from my directory, this behavior will active this program and do something what I want to do. But after I install this program as a windows service...
13
9197
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just multiple directories. I have hit a snag and don't know how to get around it. Basically I read in a list of directories from the app.config and stuff them into an array, so that I have something like this: sDirsToWatch = "C:\Temp"
3
14315
by: Stampede | last post by:
Hi, I want to use the FileSystemWatcher in a Windows Service. I read an article, where the author created the FileSystemWatcher object in a seperate thread and when the event is fired, he started a working thread for processing the file, created a new FileSystemWatcher (as he said for real time processing), and then called the join method for the first thread. I can't really see the sence in this. Aren't the events of the...
20
4524
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I'm afriad that...
12
7463
by: ljh | last post by:
Has anyone else noticed that the FileSystemWatcher raises the changed event twice when a file is changed? Do you have any idea why this is the case?
5
5609
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher, monitors a folder and then returns the contents of the new/changed files. However, if the client app loses connection to the webservice without closing the filewatcher, and then reconnects (and thus creates a new watcher), I believe I end up with...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.