Need to display file processing status

  • Thread starter Thread starter Geoff Pennington
  • Start date Start date
G

Geoff Pennington

My VB.Net app reads an Excel file, processes it one row at a time, and when
processing is complete writes the row to a database. The typical file will
have several thousand rows and may take a couple minutes to process. I would
like to display a running count of the number of rows processed. It is easy
enough to keep a counter and set the value of a textbox to the count. I
expected a high-speed odometer effect, with perhaps only the hundreds column
on up changing slowling enough to be readable, but instead the screen
"freezes" until processing is complete, at which point it shows the correct
count for total records processed. Is there a good way to show status while
processing is underway?

Much obliged.
 
Geoff Pennington said:
My VB.Net app reads an Excel file, processes it one row at a time,
and when processing is complete writes the row to a database. The
typical file will have several thousand rows and may take a couple
minutes to process. I would like to display a running count of the
number of rows processed. It is easy enough to keep a counter and set
the value of a textbox to the count. I expected a high-speed odometer
effect, with perhaps only the hundreds column on up changing slowling
enough to be readable, but instead the screen "freezes" until
processing is complete, at which point it shows the correct count for
total records processed. Is there a good way to show status while
processing is underway?

Much obliged.

Call the refresh method of the control(s) to be updated. Attention: Using
WinXP, refresh is ignored after a couple of seconds.
 
If its a windows project then you can write the record number to a tet
field, if its a console project then you can display this on the console.

Regards OHM
 
Sorry, there I go again not reading your post properly

Stick this in your loop, it should stop it freezing

System.Windows.Forms.Application.DoEvents()
OHM
 
Run the Excel file processing in a separate thread. Raise an event when you
want to update the textbox, and move the code that updates the textbox back
into the main form. Use the InvokeRequired and Invoke methods of the TextBox
control to run the UI update on the UI thread rather than the thread
processing the Excel file. You can find more information here:

http://www.devx.com/dotnet/Article/11358
 
Back
Top