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

  • Home
  • SEARCH
  • 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 8562591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:45:45+00:00 2026-06-11T16:45:45+00:00

I made a program that loads a bunch of computer information. In the Form_Load

  • 0

I made a program that loads a bunch of computer information. In the Form_Load event I have it initialize 3 (that number will grow) panels of information. One that has a bunch of unit information seems to make the program load rather slowly. I’ve tried to speed it up a bunch by switching from WMI to using Native calls, which helped a bunch. Soon though I’m going to have network information posted as well. I used to load that panel but i disabled it for a little bit till I work out the bugs in my other panels. So while learning how I can use a seperate thread to update my battery information I figured that I might be able to create seperate threads in my unit information panel so that it might could load faster. I dont know that any of my information would cause concurrent issues, but i can work on that.

I want to start small so what if i change this

    private void Form1_Load(object sender, EventArgs e)
    {
        unitInformationPanel1.PopulateUnitInformation();
        batteryInformationPanel1.InitializeBatteries();
        magStripeReaderPanel1.SetupPointOfSale();
    }

to this

    private void Form1_Load(object sender, EventArgs e)
    {
        Thread infoThread = new Thread(new ThreadStart(unitInformationPanel1.PopulateUnitInformation));
        infoThread.Start();
        batteryInformationPanel1.InitializeBatteries();
        magStripeReaderPanel1.SetupPointOfSale();
    }

would the info thread be terminated when populate unit info is done? or would it be better to move that thread creation into PopulateUnitInformation? here is what it looks like.

    public void PopulateUnitInformation()
    {
        unitModelLabel.Text = Properties.Settings.Default.UnitModelString;
        serialNumberLabel.Text = Properties.Settings.Default.UnitSerialString;
        biosVersionLabel.Text = UnitBios.GetBiosNumber();
        osLabel.Text = OS.getOSString();
        cpuLabel.Text = UnitCpu.GetCpuInfo();

        var hdd = HddInfo.GetHddInfo();
        diskNameLabel.Text = hdd.Name;
        diskCapacityLabel.Text = hdd.Capacity;
        diskFirmwareLabel.Text = hdd.Firmware;
        memoryLabel.Text = MemoryInformation.GetTotalMemory();
        NetworkPresenceInformation.GetAdapatersPresent();
        biometricLabel.Text = BiometricInformation.IsPresent ? "Present" : "Not Present";
        var networkAdaptersPresense = NetworkPresenceInformation.GetAdapatersPresent();
        bluetoothLabel.Text = networkAdaptersPresense[0] ? "Present" : "Not Present";
        wifiLabel.Text = networkAdaptersPresense[1] ? "Present" : "Not Present";
        cellularLabel.Text = networkAdaptersPresense[2] ? "Present" : "Not Present";
    }

—

wow i just ran it with the infothread and it still took some time to load (might be the 12 panels i created in the main thread. but it loaded the 12 frames and the unit information panel populated its information after everything loaded. That was cool, but is it safe? is it somewhat easy to make 12 threads for my panels? or is that dumb?

EDIT

this is what i did for stopwatch.

    Stopwatch programTimer;
    public Form1()
    {
        programTimer = Stopwatch.StartNew();
        InitializeComponent();
        SetupDebugWindow();
        TerminateKeymon();
        UnitModel.SetModel();
        UnitSerialNumber.SetSerialNumber();
    }
    private void Form1_Shown(object sender, EventArgs e)
    {
        audioBrightnessPanel1.UpdateBrightnessTrackbar();
        applicationLauncherPanel1.LoadApplications();
        programTimer.Stop();
        Console.WriteLine("Load Time: {0}",programTimer.ElapsedMilliseconds);
        timer1.Start();
    }

Will this be accurate?

EDIT 2 6/18/2012

Well I took the advice of using backgroundworker. Please let me know if i did this right.

    private void Form1_Load(object sender, EventArgs e)
    {
        backgroundWorker1.RunWorkerAsync();
    }
    void BackgroundWorker1DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
    {
        unitInformationPanel1.PopulateUnitInformation();
        batteryInformationPanel1.InitializeBatteries();
        magStripeReaderPanel1.SetupPointOfSale();
    }
  • 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-11T16:45:46+00:00Added an answer on June 11, 2026 at 4:45 pm

    So my final approach this was as follows. I felt that my Main Form was doing more than it should. Sticking with the single responsibility principle I decided that MainForm should only be responsible for one thing, showing and displaying all 12 panels (now down to 11, i turned one into a menu item). So moved all the multithreading out of mainform and into program.cs. I found that this was even a little more difficult. What I did find though was a simple solution that allows me to not even worry about multithreading at all. It was the Idle event. Here is what i chose to do.

            [STAThread]
        static void Main()
        {
            DateTime current = DateTime.Now;
            DateTime today = new DateTime(2012,7,19);
            TimeSpan span = current.Subtract(today);
            if (span.Days<0)
            {
                MessageBox.Show("Please adjust Time then restart Aspects","Adjust Time");
                Process.Start("timedate.cpl").WaitForExit();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Idle += new EventHandler(Application_Idle);
    
                mainForm = new MainForm();
                mainForm.Closing += new CancelEventHandler(mainForm_Closing);
    
                #if !DEBUG
                TerminateKeymon();
                StartSerial();
                SetupDefaultValues();
                EmbeddedMessageBox(0);
                #endif
    
                Application.Run(mainForm);
            }
        }
    
        static void Application_Idle(object sender, EventArgs e)
        {
            Application.Idle -= Application_Idle;
            mainForm.toolStripProgressBar1.Increment(1);
            UnitInformation.SetupUnitInformation();
            mainForm.toolStripProgressBar1.Increment(1);
            Aspects.Unit.HddInfo.GetHddInfo();
            mainForm.toolStripProgressBar1.Increment(1);
    
            for (int i = 0; i < mainForm.Controls.Count; i++)
            {
                if (mainForm.Controls[i] is AbstractSuperPanel)
                {
                    try
                    {
                        var startMe = mainForm.Controls[i] as AbstractSuperPanel;
                        startMe.StartWorking();
                        mainForm.toolStripProgressBar1.Increment(1);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + mainForm.Controls[i].ToString());
                    }
                }
            }
            mainForm.toolStripProgressBar1.Value = 0;
        }
    

    to sum up what that does is is I add a idle listener event. Once the thead goes idle (basically meaning that Mainform is finished drawing and making all 12 panels and is showing on my desktop) I then kill the idle event listener and tell all my panels and classes to start working one at a time, updating my progress bar as I go. It works great. The load time is still the same as it was before, but there is window visibile after only a few seconds. Maybe not the best use of resources, but i think the solution is simple and straight forward.

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

Sidebar

Related Questions

I have made a program that scans rss feeds. This same program creates feeds
is it possible to install program that i made in VS2008 (FW3.5) on computer
I have made a script that uses a program called Diascope, its a video
I have made a batch file that call another one program.bat , the first
I have made a Windows Service that gets installed in a c:\Program Files\My Service
I made a splash screen program, that loads pictures from a folder and changes
I made a program that opens an application, sleeps the thread for 500ms then
So I made a program that uses four differrent processes to do some stuff.
I made a program in Idle that says: for trial in range(3): if input('Password:')
For an assignment I've made a simple C++ program that uses a superclass (Student)

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.