473,322 Members | 1,540 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,322 software developers and data experts.

Unable to update Label in windows form

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

Similar topics

0
by: Stuart Norris | last post by:
Dear Group, I am attempting to write a "splash" and "status" Form using a second thread. I wish to use this Form to display status information to the user when I do CPU intensive work in my...
9
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and...
10
by: robwharram | last post by:
Hi, I'm quite frustrated in the fact that I can't even display a simple "Hello World" message on .Net. I've been through all of the groups and searched all over the place and haven't been able...
2
by: Rene | last post by:
Hi all i need some help. i try to send mail with the following code. Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click Dim...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
8
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In...
3
by: bhanubalaji | last post by:
hi, I am unable to disable the text(label) in javascript..it's working fine with IE,but i am using MOZILLA.. can any one help regarding this.. What's the wrong with my code? I am...
1
by: Markw | last post by:
Hi folks I think I've got a variable problem but not 100% sure. Background: I took the CMS example from chapter 6 in "Build your Own Database Driven Website Using PHP&MySQL" and have attempted to...
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.