6
可能重复:
Why does ManualResetEvent fail to work in this synchronous call using Silverlight 4?ManualResetEvent的不与WCF和Silverlight工作
我在MainPage.xaml.cs中一个下面的代码
ManualResetEvent wait = new ManualResetEvent(false);
Service1Client wcf = new Service1Client();
wcf.DoWorkCompleted += (o, ev) =>
{
int s = (int)ev.Result;
wait.Set();
};
wcf.DoWorkAsync();
wait.WaitOne();
//My other part of code where I'd like the value of `int s`.
....
Service1.svc .cs的代码如下。
public class Service1 : IService1
{
public int DoWork()
{
return 5;
}
}
截至本DoWork
完成我希望我的代码等待,所以我写了这个代码。虽然WaitOne
指令(Service1.svc.cs)方法DoWork()
完全不会被调用。应用程序将停留在那里只是不做任何事情。我之前在SilverLight 4的另一台机器上工作过,并且按预期工作。现在我正在使用SilverLight 3.
Eren我创建了全新的应用程序,并尝试相同的仍然无法正常工作。我正在使用导航应用程序。 – Shrivallabh