By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

Unable to update Label in windows form

P: n/a
Hi !

I have a little problem. I have a process that runs when a user click a
button. The process is long to execute (+/- 5 minutes). So, I put a progress
bar and now I want to show the evolution of the process in a label (Step
1/5: Create... Step 2/5 Update....etc.) I don't know why but when I try to
update the text in my label in the middle of my process (Label.text = "Step
1/5: Create...", Label.text = "Step 2/5: Update...", etc.) the label doesn't
react. It comes available only when the process is finished.

What's wrong ?

David
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Probably the UI thread waits while your other code is executing. But you can
update controls by invoking the Refresh method.
Label1.Text = "..."
Label1.Refresh
--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan

"David-L. Nadeau" <d_***@hotmail.com> schreef in bericht
news:uq**************@tk2msftngp13.phx.gbl...
Hi !

I have a little problem. I have a process that runs when a user click a
button. The process is long to execute (+/- 5 minutes). So, I put a progress bar and now I want to show the evolution of the process in a label (Step
1/5: Create... Step 2/5 Update....etc.) I don't know why but when I try to
update the text in my label in the middle of my process (Label.text = "Step 1/5: Create...", Label.text = "Step 2/5: Update...", etc.) the label doesn't react. It comes available only when the process is finished.

What's wrong ?

David

Nov 20 '05 #2

P: n/a
"Jan Tielens" <ja*@no.spam.please.leadit.be> schrieb
Probably the UI thread waits while your other code is executing. But
you can update controls by invoking the Refresh method.
Label1.Text = "..."
Label1.Refresh

Right, but ATTENTION for WinXP users: Due to a very very bad "design
change", calling Refresh is not sufficient anymore! :-(((((((((((((((((((((

3rd paragraph at
http://msdn.microsoft.com/library/en...sagequeues.asp

This is very bad because we are now FORCED to write multithreaded
applications or use Application.DoEvents although we don't want the user to
operate the application. It seems that the XP developers forgot that a
window is not only for *input* but also for *output*. A window that does not
process input messages does not necessarily mean that it does not display
something.

MSFT, please change this - at least optionally!
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #3

P: n/a
* "David-L. Nadeau" <d_***@hotmail.com> scripsit:
I have a little problem. I have a process that runs when a user click a
button. The process is long to execute (+/- 5 minutes). So, I put a progress
bar and now I want to show the evolution of the process in a label (Step
1/5: Create... Step 2/5 Update....etc.) I don't know why but when I try to
update the text in my label in the middle of my process (Label.text = "Step
1/5: Create...", Label.text = "Step 2/5: Update...", etc.) the label doesn't
react. It comes available only when the process is finished.


Call the label's 'Refresh' method.

Windows Forms + Multithreading
<http://www.devx.com/dotnet/Article/11358>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
On Thu, 4 Dec 2003 20:32:00 +0100, Armin Zingler wrote:

3rd paragraph at
http://msdn.microsoft.com/library/en...sagequeues.asp


I presume you're referring to this paragraph:

<QUOTE>
Microsoft Windows XP: If a top-level window stops responding to messages
for more than several seconds, the system considers the window to be hung.
In this case, the system hides the window and replaces it with a ghost
window that has the same Z order, location, size, and visual attributes.
This allows the user to move it, resize it, or even close the application.
However, these are the only actions available because the application is
actually hung. When in the debugger mode, the system does not generate a
ghost window.
</QUOTE>

Do you know if there is anyway to send a "Keep Alive" signal? Is DoEvents
the only thing that will do this?

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #5

P: n/a
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> schrieb
On Thu, 4 Dec 2003 20:32:00 +0100, Armin Zingler wrote:

3rd paragraph at
http://msdn.microsoft.com/library/en...sagequeues.asp
I presume you're referring to this paragraph:


yes
<QUOTE>
Microsoft Windows XP: If a top-level window stops responding to
messages for more than several seconds, the system considers the
window to be hung. In this case, the system hides the window and
replaces it with a ghost window that has the same Z order, location,
size, and visual attributes. This allows the user to move it, resize
it, or even close the application. However, these are the only
actions available because the application is actually hung. When in
the debugger mode, the system does not generate a ghost window.
</QUOTE>

Do you know if there is anyway to send a "Keep Alive" signal?
I think it is not possible.
Is
DoEvents the only thing that will do this?


Yes, DoEvents or putting the work in a different thread, so that the main UI
thread is not blocked.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.