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 6895221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:52:52+00:00 2026-05-27T06:52:52+00:00

I need an advice on how to write a windows service application that would

  • 0

I need an advice on how to write a windows service application that would monitor changes to a certain folder on a drive and copy changed and newly created files to a certain location. Now, I am going to use FileSystemWatcher for this purpose, but I wonder what would be the best way to deal with the situation when multiple files need to be copied simultaneously? For example, one huge file is still being copied and the event is fired again? Do I need to form some sort of a queue and whenever one file is finished being copied, start the next one? Or maybe create a new thread for each file and take care of the copying in that thread? Also, should I use the File.Copy method, or is there a better/faster way?

  • 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-27T06:52:52+00:00Added an answer on May 27, 2026 at 6:52 am

    I would go with the queue. The queue is filled with the file name by the event handler and a background thread processes the queue.
    If you are using .NET 4, you can use the ConcurrentQueue<T> and be thread safe.

    Non-compiling sample code:

    class AsyncFileCopier
    {
        BackgroundWorker _worker;
    
        void OnNewFile(string fileName)
        {
            _queue.Enqueue(fileName);
            EnsureWorkerIsRunning();
        }
    
        void EnsureWorkerIsRunning()
        {
            if(!_worker.IsBusy)
                _worker.RunWorkerAsync();
        }
    
        void OnWorkerDoWork(...)
        {
            string fileName;
            while(_queue.TryDequeue(out fileName)
            {
                CopyFile(fileName);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need advice on how to have my C# console application display text to
I need advice regarding subselect performance in MySQL. For a reason that I can't
I have to write an application that is essentially a proxy server to handle
I need to write a C program that will allow me to read/write files
I'm going to write my first non-Access project, and I need advice on choosing
I'm envisioning a program I will need to write and need some advice on
I need some advice on how to write a Python program where it gives
I need advice on the following HTML: <!-- Beginning of ROW !--> <div id="row1">
edit: I need advice on best way to search with regex in vim and
I'd need advice on following situation with Oracle/PostgreSQL: I have a db table with

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.