After FileSystemWatcher fires - Thread Pool or Dedicated thread?

后端 未结 3 490
耶瑟儿~
耶瑟儿~ 2021-01-19 02:20

I am about to implement the archetypal FileSystemWatcher solution. I have a directory to monitor for file creations, and the task of sucking up created files and inserting

3条回答
  •  心在旅途
    2021-01-19 03:00

    The third option is the most logical.

    In regards to FSW missing some file events, I implemented this: 1) FSW Object which fires on FileCreate 2) tmrFileCheck, ticks = 5000 (5 seconds) - Calls tmrFileChec_Tick

    When the FileCreate event occurs, if (tmrFileCheck.Enabled == false) then tmrFileCheck.Start()

    This way, after 10 seconds tmrFileCheck_Tick fires which a) tmrFileCheck.Stop() b) CheckForStragglerFiles

    Of tests I've run, this works effectively where there are a < 100 files created per minute.

    A variant is to merely have a timer tick ever NN seconds and sweep the directory(ies) for straggler files.

    Another variant is to hire me to press F5 to refresh the window and call you when there are straggler files; just a suggestion. :-P

提交回复
热议问题