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.

Signature
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
David - 15 May 2008 16:21 GMT
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.

Signature
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
> Hi all,
>
[quoted text clipped - 16 lines]
> of delaying the operation or somehow checking the file lock status and
> come back to the routine periodically.
Michael D. Ober - 16 May 2008 03:00 GMT
> Hi all,
>
[quoted text clipped - 16 lines]
> of delaying the operation or somehow checking the file lock status and
> come back to the routine periodically.
Dave,
Is the file system you are watching on a Windows Server or on the Linux
Server?
Mike Ober.
David - 16 May 2008 08:29 GMT
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
>> Hi all,
>>
[quoted text clipped - 23 lines]
>
> Mike Ober.
Michael D. Ober - 16 May 2008 12:58 GMT
> 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.
The windows server running as a VMWare guest it not an issue. However, the
mapped drive to another machine could very well be the issue. Unless the
other machine is a windows box, FSW won't work.
Mike.
> 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
[quoted text clipped - 42 lines]
>>
>> Mike Ober.