Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:42:05+00:00 2026-05-30T03:42:05+00:00

I need to create a service which is basically responsible for the following: Watch

  • 0

I need to create a service which is basically responsible for the following:

  1. Watch a specific folder for any new files created.
  2. If yes , read that file , process it and save data in DB.

For the above task, I am thinking of creating a multi threaded service with either of the following approach:

  1. In the main thread, create an instance of filesystem watcher and as soon as a new file is created, add that file in the threadQueue. There will be N no. of consumer threads running which should take a file from the queue and process it (i.e step 2).

  2. Again in the main thread, create an instance of filesystem watcher and as soon as a new file is created, read that file and add the data to MSMQ using wcf MSMQ service. When the message is read by the wcf msmq service, it will be responsible for processing further

I am a newbie when it comes to creating a multi threaded service. So not sure which will tbe the best option. Please guide me.

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:42:06+00:00Added an answer on May 30, 2026 at 3:42 am

    First off, let me say that you have taken a wise approach to do a single producer – multiple consumer model. This is the best approach in this case.

    I would go for option 1, using a ConcurrentQueue data structure, which provides you an easy way to queue tasks in a thread-safe manner. Alternatively, you can simply use the ThreadPool.QueueUserWorkItem method to send work directly to the built-in thread pool, without worrying about managing the workers or the queue explicitly.

    Edit: Regarding the reliability of FileSystemWatcher, MSDN says:

    The Windows operating system notifies your component of file changes
    in a buffer created by the FileSystemWatcher. If there are many
    changes in a short time, the buffer can overflow. This causes the
    component to lose track of changes in the directory, and it will only
    provide blanket notification. Increasing the size of the buffer with
    the InternalBufferSize property is expensive, as it comes from
    non-paged memory that cannot be swapped out to disk, so keep the
    buffer as small yet large enough to not miss any file change events.
    To avoid a buffer overflow, use the NotifyFilter and
    IncludeSubdirectories properties so you can filter out unwanted change
    notifications.

    So it depends on how often changes will occur and how much buffer you are allocating.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a service which can process queued requests on a configured
I need to create some windows service which will execute every N period of
I am new to .NET. I need to create a Web Service based on
I need to create some windows service which will execute every some often, every
I need to create a service which will maintain a WCF session. In the
I need to create a service in .NET that maintains (inner) state in-memory, spawns
I need to create a service that will be called back by a third
Anybody knows how to do this? I need to create a service that will
I need to create a photo gallery service that is managed by users. I've
I have created an web service I need to publish this service. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.