Scenario:-
Process 1 writes a file to a temp file. When it has done this it moves it to a directory "pending". Obviously the move gives an exclusive lock.
Process 2 is monitoring "pending" to look for files to process. It then process them. This is a separate thread which goes to sleep.
I have no control over process 1.
Now, process 2 will occasionally fail to process a file (not too important since it automatically tries again after a short interval). This occurs because the file locked by process 1. Obviously this is going to be the case whilst the file is being moved and before the OS has released the handle.
Of course the file can be locked at any time, it's being deserialised from XML so is initially passed to a stream reader (this throws the exception).
There isn't a time-out or any such constructor on a stream reader. Any suggestions. Not too bothered, but it's just a little messy.
Process 1 writes a file to a temp file. When it has done this it moves it to a directory "pending". Obviously the move gives an exclusive lock.
Process 2 is monitoring "pending" to look for files to process. It then process them. This is a separate thread which goes to sleep.
I have no control over process 1.
Now, process 2 will occasionally fail to process a file (not too important since it automatically tries again after a short interval). This occurs because the file locked by process 1. Obviously this is going to be the case whilst the file is being moved and before the OS has released the handle.
Of course the file can be locked at any time, it's being deserialised from XML so is initially passed to a stream reader (this throws the exception).
There isn't a time-out or any such constructor on a stream reader. Any suggestions. Not too bothered, but it's just a little messy.
Comment