.NET CF ProgressBar performance

I made an interesting discovery today. I was trying to see how long it takes to insert/update about 450 rows in a table one at a time and committing them all at the end. The performance was not horrible compared to doing something similar on SuperWaba for Pocket PC, but certainly not breathtaking – about 30 seconds if memory serves, but I didn’t have a timer on it. That is slow, but as long as it is either background process or you have a progress bar, it shouldn’t bother the user too much.

Then I tried to see what exactly was taking all the time, so I started eliminating code that was doing the insert/update until eventually, the loop was just incrementing the ProgressBar.CurrentValue and nothing else. Guess what? It was taking about 22-23 seconds!

Then I tried taking the progress bar update out and it was less than a second. Because of some dependency issues with code under development I wasn’t able to put the insert/update code back in, but I did try to only update the progress bar ever 40 ‘ticks’ and it was still less than a second.

So here’s the moral to the story: If you use a progress bar in .NET Compact Framework, the cost of an update is somewhere around .05 seconds, so limit the updates of the progress bar to a few increments. Updating the progress bar 400 times will add 20 seconds to the process, but updating it 10 times will add only .5 seconds.

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: