473,405 Members | 2,176 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,405 software developers and data experts.

SV: Updating status label and status bar

> bar.PerformStep ();
> if (bar.Value < bar.Maximum)
status.Text = "Pretending to work!";
else
status.Text = "Done.";
>
If you want to see the value at 100% before the text saying
done shows up, then you need to put a small delay in the
"else" part of your code.
I noticed that there's a property for the bar stating what time
it should take for the animation to move the fill to the
requested spot. I'm guessing that's the time i should delay
my text updating by. Correct?

When you mentioned a delay - is there an other way to do
it than threads? I've found this solution.

else {
System.Threading.Thread.Sleep (1000);
status.Text = "Done."; }

The thing is that while it postpones the text update (good,
good) it also removes the animation of the bar. By other
words - the bar waits for a second, then skips to the new
position, instead of being "pumped-up".

Most of all, it would be nice to get a report from the bar
saying "yey, i'm done animating" and then proceede.
Too much?

--
Regards
Konrad Viltersten
--------------------------------
IT-Consultant
Mandator, Fujitsu Services
0730 - 700 418
Feb 17 '08 #1
1 5777
On Sun, 17 Feb 2008 11:16:15 -0800, K Viltersten <tm**@viltersten.com
wrote:
I noticed that there's a property for the bar stating what time
it should take for the animation to move the fill to the requested spot.
What property are you referring to? If you're talking about the
ProgressBar.MarqueeAnimationSpeed property, I believe that applies only to
the marquee-style progress bar. That is, the one that just has the blocks
animating across the bar over and over, rather than reflecting actual
progress.
I'm guessing that's the time i should delay
my text updating by. Correct?
I don't think that property would be useful in this case at all. But you
could try it and see. I would try setting it to 0; if it has any effect
on a non-marquee progress bar, maybe that would make the animation go away
entirely.

But again, from the docs anyway, it doesn't look like that'd actually have
any effect for a non-marquee progress bar.
When you mentioned a delay - is there an other way to do
it than threads? I've found this solution.

else {
System.Threading.Thread.Sleep (1000);
status.Text = "Done."; }

The thing is that while it postpones the text update (good, good) it
also removes the animation of the bar. By other
words - the bar waits for a second, then skips to the new
position, instead of being "pumped-up".
Instead of blocking your thread with the Sleep() method, you could
(should, IMHO) instead use a timer or background thread. For example:

System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();

timer.Interval = 1000;
timer.Tick += delegate(object sender, EventArgs e) { status.Text =
"Done"; timer.Stop(); };
timer.Start();

Or:

BackgroundWorker bw = new BackgroundWorker();

bw.DoWork += delegate(object sender, DoWorkEventArgs e)
{ Thread.Sleep(1000); };
bw.RunWorkerCompleted += delegate(object sender,
RunWorkerCompletedEventArgs e) { status.Text = "Done"; }
bw.RunWorkerAsync();

I don't really recommend the latter, as I think it's not a great idea to
block arbitrarily in thread pool threads (and should be avoided in any
thread, for that matter). I also think the latter isn't quite as nice
just in terms of how it's put together.

But with the delay only being 1 second, it's probably not that big of a
problem if you really really wanted to.

I'd use the Timer solution though.

Either of the solutions would allow the text to not be updated until
later, while still allowing the progress bar to do the animation it wants
to do.
Most of all, it would be nice to get a report from the bar saying "yey,
i'm done animating" and then proceede.
Too much?
No, not too much. I think that given that the bar animates, it would be
nice to either have control over the animation, or to be able to receive
updates regarding the status of the animation.

But as far as I know, neither of those are options. So if you really
don't want the text updated until the progress bar has had a chance to
visually reach the end, you're stuck with hacks such as the above. If
you're going to do a hack though, at least try to make it as friendly as
possible. Blocking the GUI thread for a full second isn't very friendly..

Pete
Feb 18 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: willow1480 | last post by:
I am developing a small little Service Control Application. I am using a listview control with checkboxes and getting the list of services I want to control from a text file. When you check a...
2
by: ORC | last post by:
Hi, I have an application that has 7 forms. I would like to update the controls on the forms from a single class. How should I do that if possible? The reason for this is that my application is...
1
by: jason | last post by:
The guts of the below asp.net vb code was pieced together from another thread - all due credit to it's original author. Thank you! I've modified it to maintain a small local Microsoft 2000...
2
by: kaczmar2 | last post by:
I have an ASP.NET page written in VB.NET that has a label: <asp:Label runat="server" ID="lblStatus" CssClass="LabelTxt"></asp:Label> In my code behind, I am running some stored procedures and...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
0
by: Mike P | last post by:
I have a formview which has exactly the same parameters as a detailsview, but I get an error when I try to update when editing the formview. Here are my update parameters : <UpdateParameters>...
2
by: David Lozzi | last post by:
Howdy, I have a DetailsView that when I fire the UpdateItem event, it doesn't update the data. The page reloads and the data is set back to the original. I'm using a Button to fire the...
1
by: jonbartlam | last post by:
Hi There I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.