Problem with FileSystem watcher in a windows service

D

David

Hi all,

I have a windows service that uses the FileSystem watcher.

It is monitoring a folder for files coming in. The files are being
transferred over samba from CentOS Linux. Two files at a time.

We found that when files coming in, they were not being actioned, but when I
re-started the windows service, the files were actioned (by a slightly
different routine, but both the FSwatcher and Startup call the same
filehandling routine.)

I have had to write a log file routine to catch the errors as the machine
the service runs on is not directly accessible. (I am going over a VPN that
restricts my access). The log file is reporting that the file is being
locked by another process.

I am looking for ideas on how to get around this issue. Perhaps some way of
delaying the operation or somehow checking the file lock status and come
back to the routine periodically.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
D

David

Right, I might have solved the file locking by putting a wait loop in...

however, I would like your advice on this (and threads in general).

1. I am not using threading in my service, but my wait loop has a
thread.sleep. Does this work on the main application thread or do I need to
set up a thread?

2. As mentioned, my app is not using threading, but the app could quickly
get overloaded with files coming in. I think I may need to thread it so that
I don't get a backlog. Would that be advisable and if so, how would I go
about doing this. (I have not really done any threading before.)

Thanks.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
D

David

On the windows server (I think).

Basically, the windows server is running under VMWare. I think that the
folder I am watching is on another machine but is mounted on Windows to look
like a local drive.

I have a way that it appears to work... I am using a while loop where a
thread sleeps for 500ms per iteration (lasting a total of 10 seconds) and if
the file is still locked at that point, I guess a manual intervention will
be required.

Not sure if I am doing it the right way or not.


On another note though, should I move my file handling into another thread
and if so, how do I do that? We have the potential for 900 files coming in
at the same time. If I am sleeping the master thread (as shown above) for 10
seconds per file (not likely to happen), that could take 9000 seconds (2.5
hours) to clear the backlog.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top