Recommendations on Progress indicators

  • Thread starter Thread starter Roger H
  • Start date Start date
R

Roger H

Right now I do the following:

int count = (SELECT COUNT(*) FROM ...)

and then
++c every time I read a new record.

I then display "Reading record 'c' of 'count'" -- It works OK

Is there a better way to do this? How about using the progress bar?

When I did that last though, I had an error reinitializing it to be
able to use a new query...

Will the progress bar provide any better resiliency in the form
refresh? When I do this, if I change focus away from the application I
have a lovely white screen and no further updates.
 
Roger H said:
Right now I do the following:

int count = (SELECT COUNT(*) FROM ...)

and then
++c every time I read a new record.

I then display "Reading record 'c' of 'count'" -- It works OK

Is there a better way to do this? How about using the progress bar?

When I did that last though, I had an error reinitializing it to be
able to use a new query...

Will the progress bar provide any better resiliency in the form
refresh? When I do this, if I change focus away from the application I
have a lovely white screen and no further updates.

It sounds like you're doing your database access in the UI thread,
which is a bad idea. You should do it in a separate thread, and then
use Control.Invoke to make the updates to the UI on the UI thread.
 
It sounds like you're doing your database access in the UI thread,
which is a bad idea. You should do it in a separate thread, and then
use Control.Invoke to make the updates to the UI on the UI thread.

Why?

Cor
 
Hi Roger,

When you use a datareader, than the progress bar shows this very smooth for
the user, however it is a personal choise, when it is now fine I would not
change it. (You can also scroll back to null).

The progressbar is very easy to use it needs only the count and the steps.

I think that what you miss is that you have to refresh the control when you
are doing this kind of operations while your program is in a loop in a
method, normaly it refresh at the end of the method.

I hope this helps although it is very little of course?



Cor
 
Cor Ligthert said:

Because database access is a relatively slow process. If you do it on
the UI thread, your UI will become unresponsive (try moving another
window around in front of the UI while the query is executing).
 
Hi Jon,
Because database access is a relatively slow process. If you do it on
the UI thread, your UI will become unresponsive (try moving another
window around in front of the UI while the query is executing).
However the UI thread is doing nothing when the user ask for information, so
not using that thread will only uses extra resources to get the thread and
the interaction going.

Refreshing is very simple to do in this case. See for that my answer to the
OP.
(And needs also to be done with an extra thread)

Cor
 
However the UI thread is doing nothing when the user ask for information, so
not using that thread will only uses extra resources to get the thread and
the interaction going.

The UI thread definitely *is* doing something while the database is
being queried - it's responding to events such as repaint requests.
Also, the UI should remain responsive to things like the user closing
the application, or cancelling the request.

Doing things like database queries on the UI thread is just a bad, bad
idae.
Refreshing is very simple to do in this case. See for that my answer to the
OP.
(And needs also to be done with an extra thread)

Refreshing the UI is the job of the UI thread.
 
Also, the UI should remain responsive to things like the user closing
the application, or cancelling the request.
Exactly and therefore it is wrong to put this in a seperate thread.

Therefore you need even more resources.

Cor
 
Exactly and therefore it is wrong to put this in a seperate thread.

Eh? You've just shot your own argument in the foot.
Therefore you need even more resources.

Again, not sure what you're on about here. You need another thread, in
which to do the DB access. You keep the UI thread free from DB access,
so that it can remain responsive.
 
Back
Top