• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

How Do I create a "Busy" dialog box?

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.
0
rangers99
Asked:
rangers99
1 Solution
 
daveamourCommented:
Are you doing your work in a seperate thread?
How long are we talking about here  - seconds, minutes?
0
 
Lukasz ChmielewskiCommented:
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
0
 
daveamourCommented:
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.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
mjoachiamiakCommented:
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.
0
 
rangers99Author 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");
        }
    }
}
 
0
 
mjoachiamiakCommented:
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

0
 
Anurag ThakurTechnical ManagerCommented:
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now