What's the normal pattern for a thread to wait for file input in C# when it reaches end of file and needs to wait. Any p开发者_开发技巧articularly way of coding it, which is neat and elegant.
Thanks. Bob.
Not really a pattern but the FileSystemWatcher
(http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx) might come in handy.
I will be interested in seeing what the other answers are. I have not found an elegant solution. Here is what I have done in the past.
- Have the reader try to open the file exclusively. This will fail if the file is open elsewhere.
- Have a retry loop....sleep X milliseconds...retry Y times. Usually, I pull X & Y out into a configuration file.
Hope this helps.
Bob
精彩评论