Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a spinning wheel while application is searching database

Tags:

vb.net

spinner

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

Since the database is quite big, it sometimes takes a lot of time before the application returns the results to the interface.

I want to add some sort of spinning wheel to inform the user that the application is still searching the database and did not freeze. 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?

like image 468
GIBIT Avatar asked Feb 25 '23 17:02

GIBIT


1 Answers

Have you considered changing the mouse pointer to the hourglass as 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 display a 'spinning wheel' is probably a little more user friendly and definately a lot more obvious. So, first get hold of an animated gif that suits your needs. Then create a form that has a picture box containing the image.

Once you have that you can show the form to the user and in the background do the DB work, once this has completed close the form.

Another alternative would be to use a rolling progress bar instead, so when it reaches 100% it cycles around again and keeps going until you close it.

EDIT:

One thing that I forgot to mention is that you will have to handle exception conditions. Lets say you set the cursor to wait, then an error occurs. The exception may bypass the code that resets everything. This leaves the user with a changed cursor and no means of changing it.

When I have done this kind of thing I have typically created a disposable WaitCursor class and then used something like this:

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

In the Dispose of the WaitCursor class you set the cursor back to default. The same would apply if you went down the route of using a form with an image or progress bar.

like image 196
MrEyes Avatar answered Mar 30 '23 01:03

MrEyes