CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    107

    Angry FilesystemWatcher and thread count

    Hi,

    I have a strange problem. My c$ .net application has a filesystemwatcher that watches a specific folder and whenever there is a new file it processes it.
    When I run this app on my test machine which is win2000 professional, it works great. It has thread count of 18 and no matter how many files I put in the watched folder it processes them great without increasing the thread count. However our production site is a win 2000 server and there when the first file come in it processes (Thread count still between 14-18). But when its waiting for the next file to come in and the next one comes in the thread count increases very fast and reached upto 75 thus stalling the apllication. Can anyone see whats going on here. Can you please point me to where I can check whats happenning. Unfortunately I cannot duplicate it here to know whats going on.

    Thanks so much for all your help.

  2. #2
    Join Date
    May 2007
    Posts
    1,546

    Re: FilesystemWatcher and thread count

    Don't process the files in the callback fired by the filesystemwatcher.

    When the filesystem watcher fires and passes you the path of the file, you should add it to a queue and then process them one by one using a dedicated thread.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  3. #3
    Join Date
    Nov 2003
    Posts
    107

    Re: FilesystemWatcher and thread count

    But if the way I process the files is wrong, shouldn't I be getting the same issue on all my machines. It runs fine on all my dev machines and production sites. It has been running fine for about 2 years now. STrangely it only occurs on this win 2000 server. It basically creates a new instance of file watcher which in turn looks for files and tries to process it. So the same file is being processed more than once.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured