Delay in making control visible when connecting to database

J

Joe

I'm connecting to an Oracle database and running a query which returns
data. The query can be fairly long - 2-3 minutes. I have a label set
up on the form which is invisible to begin with. I want to make it
visible (with it's message) when the user clicks a button to run the
query. The label informs the user that the system is getting the data.

My code to do this is:

Private Sub btnRun_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnRun.Click

labWork.Visible = True

This works perfectly if no other code comes after. However, if my code
to connect to the database and run the query comes after it, then the
label does not show up until the connection to the database completes
and the data is returned.

Is there a way to force this label to be visible BEFORE the connection
to the database is made? Any ideas?

I would eventually like to use a progress bar in this case, but it was
having the same problem. I simplified it to just use a label assuming
that would be easier.

Thanks in advance.
 
G

Guest

Joe,

You might try labWork.Refresh() immediately after making the label visible.

Kerry Moorman
 
G

GhostInAK

Hello joe,

The reason your label doesn't show is because database operations (for the
most part) are blocking operations. This means that the thread they execute
in stop pumping messages while the database work is being performed. Since
you are doing this work on the UI thread, your UI becomes unresponsive.
You can instead do the work on a separate thread.. or you may wish to massage
the message pump manually from time to time.

-Boo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top