Alv*_*vin 4 c# windows-phone-8
我有下面的代码可以得到回复HTTP GET:
private void ResponseReady(IAsyncResult aResult)
{
HttpWebRequest request = aResult.AsyncState as HttpWebRequest;
try
{
this.Dispatcher.BeginInvoke(delegate()
{
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(aResult);
Run Code Online (Sandbox Code Playgroud)
当没有连接时出现问题,就会停在该response行。它没有捕获异常。是因为吗Dispatcher.Invoke?
您的异常未被捕获,因为对 BeginInvoke 的调用不会执行委托中的代码,而是将其排队以在 ThreadPool 线程上执行。当异常确实发生时,没有适当的异常处理。您是想在这里使用 Invoke 还是 BeginInvoke 吗?无论哪种方式,将异常处理放在委托中都应该可以解决您的问题。
| 归档时间: |
|
| 查看次数: |
2611 次 |
| 最近记录: |