473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2102

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bob Murdoch | last post by:
I have an ASP application that calls a COM function to create a custom report as an Excel file. This works in a synchronous fashion, as long as the report does not take too long to create. If...
5
by: hzgt9b | last post by:
Is it possible to dynamically add controls (speciifcally System.Windows.Forms.ProgressBar and System.Windows.Forms.Label) to a panel to a form and have them display (and fucntion) at run time? ...
2
by: jez123456 | last post by:
Hi, thanks for the previous advice on progressbars with showing the percentage. I would now like to create a less clunky version. I.e at the moment my progressbar shows 7 separate steps. Some...
8
by: Alexia | last post by:
Hi, I just wanted a hand on using modules. I have just managed to create a custom smooth progress bar control and i wanted to know if it is possible to insert the code in a module so it can be...
2
by: Alexia | last post by:
Hi Armin, the code i have posted is part of the onclick event for a button that starts the progress bar. The timer is also a part of the progress bar as this is a custom built control. The...
23
by: Dennis Sjogren | last post by:
Hi! I have this medium sized solution with a couple of projects and stuff. The generated application has an <appname>.exe.manifest file to enable XP themes. In the main window of the application...
2
by: Bunnist-Priest | last post by:
Hello Everyone, My first predicament is that I want to make a colomn of my vb.net DataGrid a ProgressBar colomn. (full of Pr.Bars). Is it that difficult? Is there a code example? using - Dim...
5
by: Keith Rebello | last post by:
I have a couple of progress bars that indicate the progress of a math-intensive application. They are working well. The only problem is that the progress indicator is gray in color. Is it...
2
by: Giuseppe Porcelli | last post by:
Dear All, I have a web service that return to me a big dataset. I want to know if is possible to know, during the download process, the percentual of the data been transfert. At end, I want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.