Click here to Skip to main content
14,970,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can anyone provide an example of how to use SynchronizationContext in an asp.net
application. I have a worker thread that needs to post status information to the
UI thread to display update information in a Label.Text control.
Posted

1 solution

You can't do this. It's insane. The reason is simple. ASP.NET takes a request, runs it's events and returns HTML. When your thread responds, the process could have ended, and therefore the HTML has left the building.

You can use AJAX to make info requests in a web page if you want your control to update some status.
   
Comments
Member 7969139 4-Feb-12 14:48pm
   
Makes sense what your saying but how would I give a worker thread access to a
Label control on my web page. Can you provide a example.
Member 7969139 4-Feb-12 14:52pm
   
Or are you saying when the thread ends execute some jave acript to update the control?
Christian Graus 4-Feb-12 14:54pm
   
If it makes sense, then why are you asking about worker threads ? You can't do that. It makes zero sense to do that. You have ONE thread only, and when your page is done being generated, yes, you use javascript with AJAX to update controls.

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