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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:59:05+00:00 2026-06-09T22:59:05+00:00

I am calling a login() method which handles connection to mysql server and then

  • 0

I am calling a login() method which handles connection to mysql server and then authenticating a user. Connecting to mysql server takes some time so I want to place a label which shows status of “Loading”. I am doing in it something like this:

private void button_login_Click(object sender, EventArgs e)
{
    label_status.Text = "Loading ...";
    login();
}

But I dont see label_status text changed to “Loading …”. Instead it shows this status in label_status after login function gets back.

I dont know why is this? Is this some threading issue? Any help would be appreciated.

  • 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-09T22:59:06+00:00Added an answer on June 9, 2026 at 10:59 pm

    The UI thread will be blocked for the duration of your event handler. If you want to be able to update the UI you need to perform the long running task in a non-UI thread. The BackgroundWorker is specifically designed for doing this. Here is a tutorial on how to use one.

    You should set the text before starting the BackgroundWorker, set the DoWork method to execute login and if there is any UI updates that need to happen after you login, you can call them in the Completed event.

    For smaller cases that don’t require a full BGW solution you can use the Task Parallel Library as it allows the simpler cases to remain simple. Here is the standard model for using the TPL:

    private void button1_Click(object sender, EventArgs e)
    {
        //UpdateUI with stuff to do before long running task
    
        Task.Factory.StartNew(() => someLongRunningNonUITask())
            .ContinueWith(task => updateUIWithResults(task)
               , TaskScheduler.FromCurrentSynchronizationContext());
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help. I am calling the login function from another class, //
I have got the following java class. When I am calling the login method
I'm writing an Android application which requires the user to login. I have a
In a Action, I am calling RedirectToAction(login, new { test = 1 }); And
I have an Employee class object that I am calling from my Login.aspx page's
I am Calling an Applet Class After Login. The form is Visible but the
Calling the WriteObject Method from a background thread is not possible! Is there a
Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
I have a method that A) inserts a row in a table and then
I am building an authentication system in which some information is being stored encrypted

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.