multithreading - ASP C# update content -


I think this is a simple question for you: Here we are going:

My .aspx On the page, I have a label Label1 and a button button 1 is surrounded by an updated panel.

A click on the button calls the code-back method that looks as follows:

  click protected zero (object sender, EventArgs e) {ThreadProx (" Hello "); Thread.Sleep (2000); ThreadProc ("Hello2"); Thread.Sleep (2000); ThreadProc ("Hello3"); } Zero thread process (string information) {Label1.Text = info; // UpdatePanel1.Update (); }  

What I would like to see is that the label is updated and displayed (coded) So it should be Hello , Hello2 and Hello3 to display for 2 seconds. It appears that only the last Hello3 has been provided. Can anyone explain why this happens and how can I apply my thoughts?

The work I have tried to accomplish is that a click on the button calls a multi-threaded function that checks for different pages. Whenever a worker thread comes back from its mission, then it should update a gridview with the new addition record. Here, this issue is the same: Only after completing the work, all the threads are updated, the web address is updated.

Thanks for any help!

Cheers Christoph

Because the code is running on the web server, this complete method Clicks () processes the final page rendering and sending it to the customer's web browser. Therefore, you can only see the final result, in which Label1.Text . As is "Hello3".

Thread. Sleep (2000) is on your code

However, if you want to see every update of Label1.Text , then the HTTP response to the web server is 4 instead of just a fraction of the second second. X takes seconds. / Code>, you can do this with an asynchronous AJAX call.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -