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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:23:41+00:00 2026-06-17T12:23:41+00:00

I have to process, roughly 170.000 files, and would like to use multiple threads.

  • 0

I have to process, roughly 170.000 files, and would like to use multiple threads.
The name of the files is sequential following the Year-Number format and are sorted by year in folders. (but they can be all in the same folder).
Different years have different file counts. Files are small size, only a few (10<size<20) KB each.

The order in witch they are processed is indifferent, since the output of the processing task is going to stored in a SQL Database.
What would be the best way to this? Without opening the same file twice?

  • 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-06-17T12:23:42+00:00Added an answer on June 17, 2026 at 12:23 pm

    Here is a little example:

    public static class FilesProcessor
    {
        private static List<FileProcessor> m_FileProcessors;
    
        public static void Start()
        {
            m_FileProcessors = new List<FileProcessor>();
    
            for (Int32 year = 2005; year < DateTime.Now.Year; ++year)
                InstanciateFileProcessor(year);
    
            while (!FinishedLoading())
                Application.DoEvents();
        }
    
        public static void Stop()
        {
            foreach (FileProcessor processor in m_FileProcessors)
                processor.Stop()
    
            m_FileProcessors.Clear();
            m_FileProcessors = null;
        }
    
        private static Boolean FinishedLoading()
        {
            foreach (FileProcessor processor in m_FileProcessors)
            {
                if (processor.IsAlive() && !processor.FinishedLoading())
                    return false;
            }
    
            return true;
        }
    
        private static void InstanciateFileProcessor(Int32 year)
        {
            FileProcessor processor = new FileProcessor(year);
            processor.Start();
    
            m_FileProcessors.Add(processor);
        }
    }
    

    Then the FileProcessor class:

    public sealed class FileProcessor
    {
        private Int32 m_Year;
    
        public Boolean IsAlive()
        {
            return ((m_Thread != null) && m_Thread.IsAlive);
        }
    
        public Boolean FinishedLoading()
        {
            return ((m_Thread == null) || m_Thread.Join(10));
        }
    
        public FileProcessor(Int32 year)
        {
            m_Year = year;
    
            m_Thread = new Thread(Load);
            m_Thread.Name = "Background File Processor";
        }
    
        public void Start()
        {
            if (m_Thread != null)
                m_Thread.Start();
        }
    
        public void Stop()
        {
            if ((m_Thread != null) && m_Thread.IsAlive)
                m_Thread.Abort();
        }
    
        private void Load()
        {
            // Browse the Year folder...
            // Get and read all fines one by one...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a process intensive task that I would like to run in the
I am in the process of localizing a game. I have roughly 1% of
I am developing an iOS app of which my clients would like roughly 50
I have some sgml files that are roughly standardized. However, there can be data
I have a directory full of files containing records like: FAKE ORGANIZATION 799 S
I have created an application to process log files but am having some bottle
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
Here is what I have: process = subprocess.Popen([cmd.exe, /c appcfg.py, upload_data, --config_file=..\\bulkloader.yaml, --filename= +
I want to get specific counters for processes that I have process id's for.
I have a process/Linux, which runs out of memory very soon, and I wonder

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.