ASP.NET中的SynchronizationContext [英] SynchronizationContext in asp.net

查看:116
本文介绍了ASP.NET中的SynchronizationContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以提供一个示例,说明如何在asp.net中使用SynchronizationContext
应用.我有一个工作线程,需要将状态信息发布到
UI线程,用于在Label.Text控件中显示更新信息.

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.

推荐答案

您无法执行此操作.太疯狂了原因很简单. ASP.NET接收一个请求,运行它的事件并返回HTML.当您的线程响应时,该过程可能已经结束,因此HTML离开了建筑物.

如果您希望控件更新某些状态,则可以使用AJAX在网页中发出信息请求.
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.


这篇关于ASP.NET中的SynchronizationContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆