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 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.
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
"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.
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
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
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
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
"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.
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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?
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
| |