Label not updating

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

Label not updating

 
0
  #1
Apr 9th, 2009
Hey guys,

I've got a multithreaded application done in C# but the label on one of my forms won't update! It doesn't do anything

  1.  
  2. public IndividualPCSpec(AllKnownDevicesFrm parent)
  3. {
  4. m_Parent = parent;
  5. InitializeComponent();
  6. m_IPAddressLbl.Text = "HELLO";
  7. }
  8.  
  9. public void showInformation(ComputerHardware dto)
  10. {
  11.  
  12. m_IPAddressLbl.Text = "HELLO WORLD";
  13. this.Refresh();
  14. this.m_IPAddressLbl.Refresh();
  15.  
  16. Application.DoEvents();
  17. }

I don't get why.... it doesn't even get set to "Hello"
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 139
Reputation: thoughtcoder is on a distinguished road 
Solved Threads: 12
thoughtcoder thoughtcoder is offline Offline
Junior Poster

Re: Label not updating

 
0
  #2
Apr 9th, 2009
How are you calling this functions?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 489
Reputation: Acidburn is an unknown quantity at this point 
Solved Threads: 5
Acidburn Acidburn is offline Offline
Posting Pro in Training

Re: Label not updating

 
0
  #3
Apr 9th, 2009
from another class.

  1. Class X
  2. IndividualPCSpec m_individualPC = new IndividualPCSpec (this);
  3. ComputerHardware dto = new ComputerHardware(...);
  4. ..
  5. ..
  6. Function X()
  7. {
  8. showInformation(dto);
  9. }
  10. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 139
Reputation: thoughtcoder is on a distinguished road 
Solved Threads: 12
thoughtcoder thoughtcoder is offline Offline
Junior Poster

Re: Label not updating

 
0
  #4
Apr 9th, 2009
If you attach a debugger, does it show the line m_IPAddressLbl.Text = "HELLO WORLD"; running?
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Label not updating

 
0
  #5
Apr 9th, 2009
Normally updating labels in a form is not a thread-safe operation. Check this article out:

http://msdn.microsoft.com/en-us/libr...28(VS.80).aspx

That may give you a good idea of what you have to do to update the label. You need to invoke another method to update the label's text. I'm surprised an exception is not being thrown...
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC