研究silverlight异步调用方。 Silverlight中 非UI线程更新UI 的几种方法:Delegate, AsyncOperation,BackgroundWorker 1. delegate
void DoShow(i){
this.Dispatcher.BeginInvoke( delegate { txtCalc.Text = string.format(“result “{0}”,i); }); } 2.AsyncOperation
void DoShow(i){
//这个可以写成成员变量,我这里只是为了好区分 System.ComponentModel.AsyncOperation asyncOper = System.ComponentModel.AsyncOperationManager.CreateOperation(null); asyncOper.Post(result => { txtCalc.Text = string.format(“result “{0}”,i); }, null); } 3.BackgroundWorker
参考
MSDN上的文章的
|