Click here to Skip to main content
15,921,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..,
My problem is i have two labels and two buttons in two different update panel in asp.net.
The update panels contains two buttons.
when buttons are clicked.., it will update the corresponding label text.
The issue is, suppose i gave a delay of 5 seconds in my button1_click() method, when i click button1 and button2 immediately, label2 is gettin updated.., whereas label1 is not getting updated.

can u suggest me wher im goin wrong??

this is back-end code-

C#
protected void Button1_Click2(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(5000);
            Label1.Text = "Hello";
        }
        protected void Button2_Click1(object sender, EventArgs e)
        {
            Label2.Text = "World";
        }
Posted
Comments
shefeekcm 21-Jul-11 6:30am    
just say your purpose..not clear
prince_arjun 21-Jul-11 6:54am    
@shefeekcm : my problem is button1 s action is not gettin done when second button is clicked.. when u click button1.., system goes into sleep.., meanwhile if you click button2.., the label2 is gettin updated.., but system doesn come back 2 button1 method and excute it..!
johannesnestler 21-Jul-11 10:14am    
I don't know for shure if this solves your problem but give it a try: Insert Label1.Invalidate() or if this doesn't help, Label1.Refresh() after the new text was assigned.

1 solution

You cannot sleep, put to wait state and even call any lengthy operation on your UI thread unless you want to screw up things. You should use another thread for purposes like that.

The purpose of updating a label after 5 seconds is unknown to me. You can use timer as well, but thread is the most recommended. It depends what else are your going to do.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900