C# Windows Phone 7.1:AutoResetEvent不适用于服务方法?

C# Windows Phone 7.1:AutoResetEvent不适用于服务方法?,c#,windows-phone-7.1,autoresetevent,C#,Windows Phone 7.1,Autoresetevent,在将服务引用添加到我的电话应用程序(例如)之后,我尝试使用AutoResteEvent来模拟同步方法调用。但在调用WaitOne之后,永远不会调用方法集。为什么?是虫子吗 public partial class MainPage : PhoneApplicationPage { private readonly AutoResetEvent _autoResetEvent = new AutoResetEvent(false); private string _result;

在将服务引用添加到我的电话应用程序(例如)之后,我尝试使用AutoResteEvent来模拟同步方法调用。但在调用WaitOne之后,永远不会调用方法集。为什么?是虫子吗

public partial class MainPage : PhoneApplicationPage
{
    private readonly AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
    private string _result;

    // Constructor
    public MainPage()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        var weatherSoapClient = new WeatherSoapClient();

        weatherSoapClient.GetWeatherCompleted += weatherSoapClient_GetWeatherCompleted;
        weatherSoapClient.GetWeatherAsync("Pekin");

        _autoResetEvent.WaitOne(); // Program stop hire

        textBlock1.Text = _result;
    }

    void weatherSoapClient_GetWeatherCompleted(object sender, GetWeatherCompletedEventArgs e)
    {
        _result = e.Result;
        _autoResetEvent.Set(); // Never invoke! Why???
    }
}

在WP7中,HTTP响应在UI线程上处理。阻塞UI线程会阻止处理响应。

可能存在重复的