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

The Archive Base Latest Questions

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

I have an Windows Form Application, and in it there is a Button. If

  • 0

I have an Windows Form Application, and in it there is a Button. If you click it, then a big loop with massive work is started which might take some time (up to some minutes). In that time, the Window does not react to anything, you cant even move it. Whats the way to go here? Is there a window Update function i could call? Do i have to run the loop in a new thread?

  • 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-27T09:56:53+00:00Added an answer on May 27, 2026 at 9:56 am

    Use multithreading – here is an example I wrote a while back. You basically do all your processing on another thread so it does not tie up the GUI thread.

    http://wraithnath.blogspot.com/2010/09/simple-multi-threading-example.html

    Start a new Thread on your button click (if you declare the processing thread as a member you can then stop it etc if you want to cancel the process, you can also have a IsProcessing member variable which is checked in the processing loop)

                //Create a new Thread start object passing the method to be started
                ThreadStart oThreadStart = new ThreadStart(this.DoWork);
    
                //Create a new threat passing the start details
                Thread oThread = new Thread(oThreadStart);
    
                //Optionally give the Thread a name
                oThread.Name = "Processing Thread";
    
                //Start the thread
                oThread.Start();
    

    Have a method for the processing

            /// <summary>
            /// Simulate doing work
            /// </summary>
            private void DoWork()
            {
                try
                {
                    for (int i = 0; i < m_RecordCount; i++)
                    {
                        //Sleep for 100 miliseconds to simulate work
                        Thread.Sleep(100);
    
                        //increment the progress bar by invoking it on the main window thread
                        progressBar.Invoke(
                            (MethodInvoker)
                            delegate
                            {
                                //Increment the progress bar
                                progressBar.Increment(1);
                            }
                        );
                    }
    
                    //Join the thread
                    Thread.CurrentThread.Join(0);
                }
                catch (Exception)
                {
                    throw;
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a Windows application where a button is there on a form
I have a windows forms application in .NET 3.5. There's one form with 20
Scenario I have a Windows Forms Application. Inside the main form there is a
I have a windows application in C#. I have a form. There is a
Hi there i have a windows form application and i have a datagrid with
I have a windows form application that uses a Shared class to house all
I have a Windows Form application built on a data model and a Windows
I have a Windows Form application. Version 1 of my app has been released
I have a Windows form application that's consuming web services over https and is
I have a C# Windows Form application that contains a menu with this event:

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.