我在IIS7.5和WCF回调技术上使用ASP.NET 4.0。回叫没有问题。 wcf服务可以在web客户端中触发回调方法,但它似乎在另一个线程与UI线程。如何从其他线程更新ASP.NET中textBox的值?
public partial class _Default : System.Web.UI.Page, IServiceCallback
{
private IService proxy = null;
private static TextBox _textBoxtest;
protected void Page_Load(object sender, EventArgs e)
{
_textBoxtest = TextBox1;
}
protected void Button1_Click(object sender, EventArgs e)
{
//then server will call back to FireCallBackFromServer
proxy.CallService(type, "someObject");
}
#region IServiceCallback Members
public void FireCallBackFromServer(string txt)
{
TextBox1.Text = txt; <-- the value does not update on textBox
}
#endregion
}
请帮我想想如何从回调事件更新我的文本框。
谢谢。
我已经创建了静态变量来存储从回调返回的消息,并使用定时器轮询此变量中的值以在UI上进行更新。它可以工作,但这只是一个文本框。我没有一个想法,但如何处理多个UI对象。 – tong 2011-03-06 06:50:48