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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:43:44+00:00 2026-06-14T07:43:44+00:00

All, I want to update a ToolStripMenu to show an SqlConnection failure. I want

  • 0

All, I want to update a ToolStripMenu to show an SqlConnection failure. I want the error message to display for some time timeToWaitMs (in milli-second) and then refresh the UI back to an okay state after some time and some operations. Currently I am doing (with some un-necessary details removed)

public void ShowErrorWithReturnTimer(string errorMessage, int timeToWaitMs = 5000)
{
    // Update the UI (and images/colors etc.).
    this.toolStripLabelState.Text = errorMessage;

    // Wait for timeToWait and return to the default UI.
    Task task = null;
    task = Task.Factory.StartNew(() =>
        {
            task.Wait(timeToWaitMs);
        });

    // Update the UI returning to the valid connection.
    task.ContinueWith(ant =>
        {
            try
            {
                // Connection good to go (retore valid connection update UI etc.)!
                this.toolStripLabelState.Text = "Connected";
            }
            finally
            {
                RefreshDatabaseStructure();
                task.Dispose();
            }
        }, CancellationToken.None,
            TaskContinuationOptions.None,
            mainUiScheduler);
}

The problem I have is that task.Wait(timeToWaitMs); is causing a Cursors.WaitCursor to be displayed – I don’t want this. How can I force the error message to be displayed for a period, after which I return to a non-error state?

Thanks for your time.

  • 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-14T07:43:45+00:00Added an answer on June 14, 2026 at 7:43 am

    I wouldn’t use a task at all here – at least not without the async features in C# 5. In C# 5 you could just write:

    await Task.Delay(millisToWait);
    

    But until you’ve got that, I’d just use a timer appropriate for your UI, e.g. System.Windows.Forms.Timer or System.Windows.Threading.DispatcherTimer. Just use what you’ve currently got as a continuation as the “tick” handler for the timer, and schedule it appropriately.

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

Sidebar

Related Questions

I want update some of my table in database and want all of these
For example I want to update all records to '2012-01-01' ( time : ISODate(2011-12-31T13:52:40Z)
What I want: Update all new commits from server with my local repository in
i want to update all records in my database(mongodb),I tried to use command below
I want to select multiple rows from checkbox and want to update them all
I have an ORM mapped object, that I want to update. I have all
I want to perform an update on all the rows in an XML column
I want to know if there's any way to update from all versions (Example:
I want to update all field values (of a custom field) to a specific
i have a query like below and i want to update all elements of

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.