我正在使用Silverlight 4和WCF服務進行數據庫交互。我面臨着一個問題。使用WCF方法異步調用結果
Silverlight應用程序中的所有函數。
ServiceReference1.WCFSLServicesClient wc = new ServiceReference1.WCFSLServicesClient();
private void button1_Click(object sender, RoutedEventArgs e)
{
_wait = new ManualResetEvent(false);
wc.SayHelloCompleted += new EventHandler<ServiceReference1.SayHelloCompletedEventArgs>(wc_SayHelloCompleted);
wc.SayHelloAsync("Mr. X");
//wait untill the call finish and then move next like
//Here I want to do some thing with result of above call. And then proceed to next task .
}
String Name = String.Empty;
void wc_SayHelloCompleted(object sender, ServiceReference1.SayHelloCompletedEventArgs e)
{
Name =e.Result;
}
但所有方法銀光調用是異步,所以我不能夠得到這一點。
我也發現了同樣的在上面這個鏈接http://www.codeproject.com/KB/silverlight/SyncCallInSilverlight.aspx?msg=3571404但使用的JavaScript的我的應用程序運行時OOB – JSJ 2011-03-11 13:26:34