Solved

WaitCursor Between forms often doesn't show up

Posted on 2010-08-17
3
1,022 Views
Last Modified: 2013-12-21
I try to set Cursor.Current=Cursors.WaitCursor, when ever I have a long running operation.  However, I'm noticing, that sometimes it doesn't work or there is a significant delay.  The biggest culprit is when I set it before loading and showing a modal form, ie...

      Cursor.Current = Cursors.WaitCursor;
      Form formToLoad = null;
      switch (formNumber)
      {
        case "1":
          formToLoad = new App1MainMenu();
          break;
        case "2":
          formToLoad = new App2.FDEMainMenu();
          break;
      }
      if (formToLoad != null)
        formToLoad.ShowDialog();


If I break in the debugger prior to the showdialog line, it works fine.  Some ShowDialog trickery in my baseclass also works:

    private void BaseForm_Activated(object sender, EventArgs e)
    {
      Timer cursorTimer = new Timer();
      cursorTimer.Tick += new EventHandler(cursorTimer_Tick);
      cursorTimer.Interval = 500;
      cursorTimer.Enabled = true;

    }

    void cursorTimer_Tick(object sender, EventArgs e)
    {
      Cursor.Current = Cursors.Default;
      ((Timer)sender).Enabled = false;

    }


    new public DialogResult ShowDialog()
    {
      Cursor.Current = Cursors.WaitCursor;
      return base.ShowDialog();
    }


Is there a better way to do this?
0
Comment
Question by:b_levitt
3 Comments
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 500 total points
ID: 33455846
try

Application.DoEvents();

to force it processing all events
0
 
LVL 2

Expert Comment

by:Raymond-Holmboe
ID: 33463462
also, Cursor.Show() may work, right after you change the cursor.
0
 
LVL 11

Author Comment

by:b_levitt
ID: 33991402
I appologize for the delay.  While I've not had a chance to test this fully, DoEvents did seem to work.  Cursor.Show did not.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question