Form not refreshing

  • Thread starter Thread starter Steve Hoyer
  • Start date Start date
S

Steve Hoyer

Good day.

I wrote an application to convert data from one database to another. It
runs through about 100,000 records for this conversion. That bit works
fine.

I have on the form a progress bar and a label to tell me how far it has
gotten and what record it is currently on, respectively.

The problem is that usually (but not always), as it is processing
records, the form stops refreshing and appears to hang. I am even told
by Task Manager that it is Not Responding. However, the hard drive is
churning, and if I leave it go for a while, it will eventually finish
processing.

This happens during debug as well. I can pause it in debug and see that
it is running (the counters continue incrementing). If I pause and step
through to just after my me.refresh (which happens at the end the
process of each record), it still doesn't actually refresh the form.

Thanks for any help.

Steve Hoyer


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Hi,

Place Application.DoEvents in your loop. It will allow the form to
update itself.


Ken
--------------
 
* Steve Hoyer said:
I wrote an application to convert data from one database to another. It
runs through about 100,000 records for this conversion. That bit works
fine.

I have on the form a progress bar and a label to tell me how far it has
gotten and what record it is currently on, respectively.

You could call 'Application.DoEvents' every n-th dataset you are
processing, or you could move the processing stuff into a separate
thread that updates the UI using invoke. A sample for thread-safe
updating an UI from another thread can be found here:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>
 
I added the doevents so it runs every 100 records and it works great.
Thank you.

Steve Hoyer


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Back
Top