Home All Groups Group Topic Archive Search About

Delay in making control visible when connecting to database

Author
7 Aug 2006 5:09 PM
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.

Author
7 Aug 2006 7:02 PM
Kerry Moorman
Joe,

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

Kerry Moorman


Show quoteHide quote
"Joe" wrote:

> 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.
>
>
Author
7 Aug 2006 8:16 PM
Joe
Kerry,

That did it.  Thanks!

-Joe
Author
7 Aug 2006 8:52 PM
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

Show quoteHide quote
> 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.
>