|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
FileSystemWatcher - setup a sequence of calls (one file after another)?Hi folks,
I have an application with a separate thread that copies files between directories. In the GUI-thread, I have a FileSystemWatcher running that monitors the target-directory the second thread copies the files into and processes those files. However, some files will take longer than others to process, but they still need to be processed in the order they were created. Is there a way of "locking" the FSW's .Created-event so that subsequent calls would wait until a possibly running event has finished? I thought that using Monitor.Enter/Monitor.Exit would do the trick, but it doesn't ... :-( Thanks for any suggestions! Cheers, Olaf Olaf Rabbachin wrote:
Show quoteHide quote > Hi folks, I think your best bet here is to queue up your events. When the FSWer > > I have an application with a separate thread that copies files between > directories. In the GUI-thread, I have a FileSystemWatcher running that > monitors the target-directory the second thread copies the files into and > processes those files. However, some files will take longer than others to > process, but they still need to be processed in the order they were > created. Is there a way of "locking" the FSW's .Created-event so that > subsequent calls would wait until a possibly running event has finished? > I thought that using Monitor.Enter/Monitor.Exit would do the trick, but it > doesn't ... :-( > > Thanks for any suggestions! > > Cheers, > Olaf fires an event, add it to a queue. Have your worker thread just process the queue. Chris |
|||||||||||||||||||||||