2011-09-30 4 views
0

내 전화 응용 프로그램에 서비스 참조 (예 : http://www.deeptraining.com/webservices/weather.asmx?op=GetWeather)를 추가 한 후 AutoResetEvent를 에뮬레이션 동기 메서드 호출에 사용하려고했습니다. 그러나 WaitOne을 호출 한 후에 Set 메서드는 호출되지 않습니다. 왜? 그게 버그 야?Windows Phone 7.1 : 서비스 메서드에서 AutoResetEvent가 작동하지 않습니까?

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??? 
    } 
} 
+0

결과를 검색 할 때 [DownloadStringTaskAsync에서 WP7이 중단됨] 가능한 복제본 (http://stackoverflow.com/questions/6448819/downloadstringtaskasync-on-wp7-hangs-when-retrieving-result) –

답변

0

WP7에서 HTTP 응답은 UI 스레드에서 처리됩니다. UI 스레드를 Bocking하면 응답이 처리되지 않습니다.

관련 문제