Add a spinning wheel when the application searches the database

I have an application that is looking for some information in a database.

Since the database is quite large, sometimes it takes a long time before the application returns the results to the interface.

I want to add some kind of spinning wheel to inform the user that the application is still looking for a database and is not freezing. Once the results are returned, the wheel should disappear.

Any idea how to do this, or is there a good tutorial explaining how to do this?

+4
source share
3 answers

Have you considered changing the mouse pointer to an hourglass since this would be extremely simple to implement:

Me.Cursor = Cursors.WaitCursor ...Do your DB calls here... Me.Cursor = Cursors.Default 

However, I would agree that the “spinning wheel” display is probably a bit more user friendly and certainly much more obvious. So first get an animated gif that suits your needs. Then create a form in which there is a window with an image.

After that, you can show the form to the user and work in the background with the database as soon as this completes closing the form.

Another alternative would be to use a moving progress bar, so when it reaches 100%, it moves again cyclically and continues to move until you close it.

EDIT:

One thing that I forgot to mention is that you have to handle exception conditions. Suppose you make the cursor wait, then an error occurs. An exception might bypass code that flushes everything. This leaves the user with the cursor changed and no means to change it.

When I did this, I usually created a one-time WaitCursor class, and then used something like this:

 Using myWaitCursor As WaitCursor = New WaitCursor ...do something... End Using 

In the WaitCursor class Utility, you will return the default cursor. The same would apply if you took the path of using a form with an image or progress bar.

+5
source

Find an animated gif of such a counter, for example this one . Put it in the PictureBox, set the Visible property to True when the task starts. Remember that you will have to run the request in the workflow to liven up the animation and the user interface to respond. The BackgroundWorker class is good for this.

+3
source

You can use the default wait cursor for the environment, which for Vista / 7 is a circle with external rotation or the XP clock glass.

You can start your database access on BackgroundWorker and show an animated control, such as the Marquee progress bar, or you can show custom animations to display the busy status.

0
source

All Articles