471,305 Members | 1,180 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

progressbars

Hi,
I have a very processor intensive method, and I want to report its
progress. When i get it to update a progressbar, label, print to console
etc. it vastly slows the method down.

Is there a way to avoid this?

Thanks

Andrew
Feb 13 '06 #1
10 2068

"Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
message news:Dc*******************@newsfe7-win.ntli.net...
| Hi,
|
|
| I have a very processor intensive method, and I want to report its
| progress. When i get it to update a progressbar, label, print to console
| etc. it vastly slows the method down.
|
| Is there a way to avoid this?
|
| Thanks
|
| Andrew

I suppose you run this on an auxiliary thread, right?, How often do you
update the progress bar?
It's quite normal that this has some impact on performance when it happens
too often.
Willy.
Feb 13 '06 #2
Willy Denoyette [MVP] wrote:
"Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
message news:Dc*******************@newsfe7-win.ntli.net...
| Hi,
|
|
| I have a very processor intensive method, and I want to report its
| progress. When i get it to update a progressbar, label, print to console
| etc. it vastly slows the method down.
|
| Is there a way to avoid this?
|
| Thanks
|
| Andrew

I suppose you run this on an auxiliary thread, right?, How often do you
update the progress bar?
It's quite normal that this has some impact on performance when it happens
too often.
Willy.


Hi, no I dont run it on an aux thread. Would doing this increase
performance wrt updating a prgbar?
Thanks

Andrew
Feb 13 '06 #3

"Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
message news:7z*******************@newsfe7-gui.ntli.net...
| Willy Denoyette [MVP] wrote:
| > "Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
| > message news:Dc*******************@newsfe7-win.ntli.net...
| > | Hi,
| > |
| > |
| > | I have a very processor intensive method, and I want to report its
| > | progress. When i get it to update a progressbar, label, print to
console
| > | etc. it vastly slows the method down.
| > |
| > | Is there a way to avoid this?
| > |
| > | Thanks
| > |
| > | Andrew
| >
| > I suppose you run this on an auxiliary thread, right?, How often do you
| > update the progress bar?
| > It's quite normal that this has some impact on performance when it
happens
| > too often.
| >
| >
| > Willy.
| >
| >
|
| Hi, no I dont run it on an aux thread. Would doing this increase
| performance wrt updating a prgbar?
|

No, it won't, but it keeps the UI responsive. Whenever you interrupt your
"processor bound" code path to update the UI it's gonna hurt your
performance, unless you run this on a multi-core or HT CPU.
Willy.
Feb 13 '06 #4
Willy Denoyette [MVP] wrote:
"Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
message news:7z*******************@newsfe7-gui.ntli.net...
| Willy Denoyette [MVP] wrote:
| > "Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
| > message news:Dc*******************@newsfe7-win.ntli.net...
| > | Hi,
| > |
| > |
| > | I have a very processor intensive method, and I want to report its
| > | progress. When i get it to update a progressbar, label, print to
console
| > | etc. it vastly slows the method down.
| > |
| > | Is there a way to avoid this?
| > |
| > | Thanks
| > |
| > | Andrew
| >
| > I suppose you run this on an auxiliary thread, right?, How often do you
| > update the progress bar?
| > It's quite normal that this has some impact on performance when it
happens
| > too often.
| >
| >
| > Willy.
| >
| >
|
| Hi, no I dont run it on an aux thread. Would doing this increase
| performance wrt updating a prgbar?
|

No, it won't, but it keeps the UI responsive. Whenever you interrupt your
"processor bound" code path to update the UI it's gonna hurt your
performance, unless you run this on a multi-core or HT CPU.
Willy.


Oh right, ok thanks!

How exactly would i go about doing this?
Here is my code:

myClass x = new myClass;
x.run();

Thanks

Andrew
Feb 13 '06 #5
Yes it slows down everything if you change progress bar too often - let's say
10000 times. Such a big number of steps usually means that most of the time
your progress bar is not moving on every step so you don't have to change it
so often anyway. Thus solution: change progress bar not on every step but on
every nth step where n = 100 or 1000 for example.

"Andrew Bullock" wrote:
Hi,
I have a very processor intensive method, and I want to report its
progress. When i get it to update a progressbar, label, print to console
etc. it vastly slows the method down.

Is there a way to avoid this?

Thanks

Andrew

Feb 13 '06 #6
Andrew Bullock wrote:
I have a very processor intensive method, and I want to report its
progress. When i get it to update a progressbar, label, print to console
etc. it vastly slows the method down.

Is there a way to avoid this?


Hard to say without seeing your code. I'd guess that you're maybe doing
some kind of calculation or something that is slowing everything down,
but it's difficult to tell without knowing, for example, if your code is
executing a loop 1,000,000,000 times or something, in which case,
updating a progress bar on each iteration could affect performance greatly.

Maybe you could add a Timer object and update the progress when a "tick"
event is raised.

Again, it's too hard for me to tell you for sure without seeing the code.

Good luck and hope that helps,

--
Sean
Feb 13 '06 #7
Willy Denoyette [MVP] wrote:
"Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
message news:Dc*******************@newsfe7-win.ntli.net...
| Hi,
|
|
| I have a very processor intensive method, and I want to report its
| progress. When i get it to update a progressbar, label, print to console
| etc. it vastly slows the method down.
|
| Is there a way to avoid this?
|
| Thanks
|
| Andrew

I suppose you run this on an auxiliary thread, right?, How often do you
update the progress bar?


I hope I'm not going off topic here, but did you mean update the
progress bar in an auxiliary thread? I ask because I was once told that
it wasn't good to update the UI from any thread but the parent. Is that
not true?

Thank you,

--
Sean
Feb 13 '06 #8

"Fao, Sean" <en**********@yahoo.comI-WANT-NO-SPAM> wrote in message
news:OW**************@TK2MSFTNGP14.phx.gbl...
| Willy Denoyette [MVP] wrote:
| > "Andrew Bullock" <an*********************@ANDntlworldTHIS.com> wrote in
| > message news:Dc*******************@newsfe7-win.ntli.net...
| > | Hi,
| > |
| > |
| > | I have a very processor intensive method, and I want to report its
| > | progress. When i get it to update a progressbar, label, print to
console
| > | etc. it vastly slows the method down.
| > |
| > | Is there a way to avoid this?
| > |
| > | Thanks
| > |
| > | Andrew
| >
| > I suppose you run this on an auxiliary thread, right?, How often do you
| > update the progress bar?
|
| I hope I'm not going off topic here, but did you mean update the
| progress bar in an auxiliary thread? I ask because I was once told that
| it wasn't good to update the UI from any thread but the parent. Is that
| not true?
|
| Thank you,
|
| --
| Sean

Yes it's true that you should not "directly" update UI elements from non UI
threads, you need to marshal the call by using Control.Invoke or BeginInvoke
or a BackgroudWorker in V2 of the framework.

Willy.
Feb 13 '06 #9
On Mon, 13 Feb 2006 16:11:15 GMT, Andrew Bullock
<an*********************@ANDntlworldTHIS.com> wrote:
Hi,
I have a very processor intensive method, and I want to report its
progress. When i get it to update a progressbar, label, print to console
etc. it vastly slows the method down.

Is there a way to avoid this?

Thanks

Andrew


If you are using .NET 2.0 you can set the ProgressBar Style property
to Marquee. When you set it that way the progress bar will display
blocks that continuously scrolled fro left to right until you
terminate the scrolling. This is a good way to indicate processing
when you don't know how may things you are processing.

I suspect it would help your speed issue also.

Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Feb 14 '06 #10
Willy Denoyette [MVP] wrote:
"Fao, Sean" <en**********@yahoo.comI-WANT-NO-SPAM> wrote in message
| Willy Denoyette [MVP] wrote:
| > I suppose you run this on an auxiliary thread, right?, How often do you
| > update the progress bar?
|
| I hope I'm not going off topic here, but did you mean update the
| progress bar in an auxiliary thread? I ask because I was once told that
| it wasn't good to update the UI from any thread but the parent. Is that
| not true? Yes it's true that you should not "directly" update UI elements from non UI
threads, you need to marshal the call by using Control.Invoke or BeginInvoke
or a BackgroudWorker in V2 of the framework.

Thank you for clearing that up,

--
Sean
Feb 15 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bob Murdoch | last post: by
5 posts views Thread by hzgt9b | last post: by
2 posts views Thread by jez123456 | last post: by
8 posts views Thread by Alexia | last post: by
2 posts views Thread by Alexia | last post: by
5 posts views Thread by Keith Rebello | last post: by
2 posts views Thread by Giuseppe Porcelli | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.