How to display a record counter on a form?

T

Tony Girgenti

Hello.

Developing VS2005, SP1, .NET 2.0, VB Windows form program on WIN XP Pro,
SP2.

The program reads a large amount of records from a flatfile. While it is
doing that i tried to display a record counter in a label control. The
only way i could think of to do this is to use the following code:

recordsReadCounter +=1
Me.recordsReadLabel.Text = recordsReadCounter.ToString
Me.Refresh()

The problem is that sometimes it displays the counter as it changes for a
while, but then it just stops displaying and sits with an hour glass until
it finishes and finally displays the total count. If i minimize the window
and go back to it, the counter is not moving and again it sits there with an
hour glass until it finishes.

It seems to stop displaying the counter at different counts, sometimes at a
low count and at other times a high count, but it always displays the
correct count when it finishes.

Is there a way to display a record count where it displays continuously
until it is finished?

I'm not looking for a progress bar. I just want to display the record count
after each record is read.

Any help would be gratefully appreciated.

Thanks,
Tony
 
V

VJ

Looks like the display Control is not painting as needed. Real quick fix is
to do this

Label1.Text = "Counter" + i.ToString();
Application.DoEvents(); //refresh and repaint.!

Not desirable, but will tell you if it works and runs as expected or if
there are other issues. What we have done is to put up a splash screen when
executing such process and then keep updating the splash screen. The code
that executs the process runs in a separate thread, the UI or Application
thread displays splash screen and keeps updating messages. What this does is
does not lock the UI refresh when updating , which happens in your case.

If you need help in using threads, please ask
VJ
 

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

Similar Threads


Top