veljkoz
veljkoz

Reputation: 8514

How to show and hide the "Please wait" message for user

I have a code that executes for some time on GUI thread (to simplify things, let's assume in Button_Click event).

When the method starts I'd like to show a message "Please wait", and continue working. When the work is done I'll hide the message and continue.

I know I can do this with BackgroundWorker (or any other Thread related), but I was hoping there's something already finished like:

MBox.Show("Please wait...");
//do my work...
MBox.Hide();

Upvotes: 1

Views: 2175

Answers (3)

Kevin Gale
Kevin Gale

Reputation: 4458

You could create your own form to do this. There is nothing inherently evil about making the user wait if they would expect to wait or are required to wait. We have applications where the normal work flow requires a short wait. Placing it in a background thread doesn't help the user since they still need to wait for the operation to finish before they can do anything else.

Upvotes: 0

Saeed Amiri
Saeed Amiri

Reputation: 22555

If you using .Net 4 you can run a Task to work with your background worker, else you can do threading, but they shouldn't be in same thread.

Upvotes: 1

Bryan
Bryan

Reputation: 2791

If you have some long running process, you should not be doing this in the UI thread. What is wrong with BackgoundWorker? That class is great! I would recommend that you use that if this is a WinForms app.

Upvotes: 3

Related Questions