0

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

public IndividualPCSpec(AllKnownDevicesFrm parent)
        {
            m_Parent = parent;
            InitializeComponent();
            m_IPAddressLbl.Text = "HELLO";
        }

        public void showInformation(ComputerHardware dto) 
        {
            
            m_IPAddressLbl.Text = "HELLO WORLD";
            this.Refresh();
            this.m_IPAddressLbl.Refresh();

            Application.DoEvents();
        }

I don't get why.... it doesn't even get set to "Hello" :S

3
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by alc6379
0

from another class.

Class X
IndividualPCSpec m_individualPC = new IndividualPCSpec (this);
ComputerHardware  dto = new ComputerHardware(...);
..
..
Function X() 
{
showInformation(dto);
}
}
0

Normally updating labels in a form is not a thread-safe operation. Check this article out:

http://msdn.microsoft.com/en-us/library/ms171728(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...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.