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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:33:10+00:00 2026-05-25T23:33:10+00:00

I have written a program in C#. Now I finished all the functionality and

  • 0

I have written a program in C#. Now I finished all the functionality and it works. But only running with one thread. I’m doing a lot of calculation and sometimes loading about 300 MB or more of measurement files into the application.

I now want to make the program multithreaded because the user experiance is really bad in times of intense processing or i/o operations.

What is the best way to refactor the program, so that it can be made multithreaded without too much affort? I know this is stuff I should have thougth before. But I havn’t.

I used the singleton pattern for about 3 big and important modules which are involved in nearly every other functionality of the program.

I used a more or less clean MVC (Model View Control) architecture. So I wonder if it is maybe possible to let the User Interface run in one thread and the rest of the application in another.

If not, loading and parsing 300MB, creating objects will take about 3 minutes to finish. In this time the user gets no response from the GUI. :/

UPDATE:
My singletons are used as a kind of storage. One singleton saves the objects of the parsed measurement files, while the other singleton saves the result. I have different calculations, which use the same measurementfiles and creating results which they want to save using the other singleton. This is one problem.

The second is to keep the guy responsive to user action or at least avoid this warning that the window is not responding.

Thank you all for all advices. I will try them. Sorry for the late answere.

  • 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-25T23:33:11+00:00Added an answer on May 25, 2026 at 11:33 pm

    The easiest way is to move all calculations to one separate thread and update the GUI using Invoke/InvokeRequired.

    public partial class MyForm : Form
    {
        Thread _workerThread;
    
        public MyForm()
        {
            _workerThread = new Thread(Calculate);
        }
    
        public void StartCalc()
        {
            _workerThread.Start();
        }
    
        public void Calculate()
        {
            //call singleton here
    
    
        }
    
        // true if user are allowed to change calc settings
        public bool CanUpdateSettings
        {
            get { return !_workerThread.IsAlive; } }
        }
    }
    

    In this way you have get a response GUI while the calculations are running.

    The application will be thread safe as long as you don’t allow the user to make changes during a running calculation.

    Using several threads for doing the calculations is a much more complex story which we need more information for to give you a proper answer.

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

Sidebar

Related Questions

see i have written one program for big endian now i dont have big
I have written a program that uses qhttp to get a webpage. This works
I have written a java program that is actually works as a gui to
I have written a program which works on huge set of data. My CPU
I have written a program that relies on a proxy to function. I now
I have written a C++ program (which executes from the command line), that works
I have a program written in C#, running on Linux using Mono. The program
I am new to programing. Now I have written a c program(simple calculator) and
I have a program written in C, which includes 2 functions, one function is
I have written c++ program on NetBeans, now I want to run it on

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.