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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:38:40+00:00 2026-06-07T13:38:40+00:00

I have a simple form that is supposed to start a timer, perform a

  • 0

I have a simple form that is supposed to start a timer, perform a time-consuming operation, and update a progress bar at a certain interval while that operation is working. Right now, the time-consuming operation is bound to a SearchButton. However, nothing happens with the progress bar, even though the time-consuming operation (in this case a download) does take several seconds:

public partial class Form1 : Form
{
    System.Windows.Forms.Timer searchProgressTimer;

    public Form1()
    {
        InitializeComponent();
        this.searchProgressTimer = new System.Windows.Forms.Timer();
    }

    private void InitializeTimer()
    {
        this.searchProgressTimer.Interval = 250;
        this.searchProgressTimer.Tick += new EventHandler(searchProgressTimer_Tick);
    }

    void searchProgressTimer_Tick(object sender, EventArgs e)
    {
        searchProgressBar.Increment(1);
        if (searchProgressBar.Value == searchProgressBar.Maximum)
            this.searchProgressTimer.Stop();
    }

    private void SearchDatabase_Click(object sender, EventArgs e)
    {
        this.searchProgressTimer.Start();

        // Time-consuming operation
        String filename = @"http://www.bankofengland.co.uk/publications/Documents/quarterlybulletin/qb0704.pdf";
        WebClient webClient = new WebClient();
        webClient.DownloadFileAsync(new Uri(filename), @"file.pdf");
        int test;
        for (int i = 0; i < 100000; i++)
            for (int j = 0; j < 100000; j++)
                test = i + j;


        this.searchProgressTimer.Stop();

    }
}

(The functions are named a tad strangely because the actual time-consuming operation is a database search, but that code, although working correctly, is extremely long and involved).

Debugging this code just shows me that the SearchButton_Click event handler fires correctly, but the code never jumps to the searchProgressTimer_Tick event handler. Any ideas?

  • 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-07T13:38:42+00:00Added an answer on June 7, 2026 at 1:38 pm

    So 1) I don’t see a call to InitializerTimer() anywhere.

    and 2) System.Windows.Forms.Timer raises its tick event on the UI thread.. the very same thread you are doing your time consuming op on. You will need to yield control to the message pump once in a while in order for the even to be processed.

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

Sidebar

Related Questions

I have a simple form that's supposed to enter submissions in a MySQL database
I have a simple form that looks like this: <%= simple_form_for @study,:url => studies_path,
I have a simple form that looks like so <% remote_form_for post, :url =>
I have a simple form that searches through the 2000+ issues of a 3rd
So i have a simple form that takes a few inputs (two text and
I currently have a simple form that when you click the save button will
I'm creating a form. As of right now I have simple MAILTO form that
I have simple php validation form that is halfway working. If you leave the
I have a simple html form that looks like the following <form action=search.php method=get>
I have a simple Windows Form that hosts property controls at runtime. When the

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.