We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

How Do I create a "Busy" dialog box?

rangers99
rangers99 asked
on
Medium Priority
375 Views
Last Modified: 2013-11-27
Im developing a Windows (NOT internet based) application using Visual C# and Visual Studio. My program does a lot of processing and sometimes it may look to the user as though its stuck in an infinite loop or something. The only thing that is displayed is the Windows (Vista)  busy revolving  circle thingie. Ideally Id like a dialog box to be displayed that says "Dont panic, everything is working OK. Just be patient!".

Can someone explain how I do this? Thanks.
Comment
Watch Question

Are you doing your work in a seperate thread?
How long are we talking about here  - seconds, minutes?
throw the working function into backgroundworker thread
OR
display a baloontip previous to running time-taking function and undisplay it after

here is the vb.net version but i'm sure it's pretty much the same in c#
http://vbnet.mvps.org/index.html?code/subclass/shellnotifyballoontip.htm
Yep I was going to contine with suggesting a seperate thread and then some kind of delegate event so that the form knows how the thread is progressing and can update some kind of visual progress control - eg a progress bar.
The simplest thing is to create modeless dialog . And then in the function which is causing high CPU load before expected bottleneck  you call your modeless dialog with static text in it informing the user that some operation is in progress.

Author

Commented:
mjoachiamiak
I like this idea becuase Im looking for as simple a solution as possible. Can you post the code to make this work. I tried the following below but the message I had in the bust form did not display.


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            busy frm = new busy();
            frm.Show();

            Thread.Sleep(10000);
           
            MessageBox.Show("Finished");
        }
    }
}
 
Well.
The code above works for me. I ma using C++. Please try to call DoEvents() function to let the system process all messages before you run your time expensive code. Maybe the system hasn't enough time to show the form.
Good luck.
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
			  
			  busy frm;
				frm.Show();
				Application::DoEvents();
				System::Threading::Thread::Sleep(2000);
         			MessageBox::Show("Finished");
			 }
	};
}

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.