簡體   English   中英

異步連接到WCF服務時處理CommunicationException

[英]Handling a CommunicationException when connecting to WCF service asynchronously

我正在使用Windows Phone 8應用程序中的WCF Web服務,(由於某種原因)我想處理電話沒有互聯網的情況。

問題是,我正在異步調用WCF Web服務功能,所以我不能只是嘗試/捕獲CommunicationException? 該怎么辦?

這是我的一些代碼:

BusWebService.BusServiceClient ServiceClient;

ServiceClient = new BusWebService.BusServiceClient();
ServiceClient.GetTestBusesCompleted +=
                new EventHandler<BusWebService.GetTestBusesCompletedEventArgs>(GetTestBusesCompleted);

//Try or Catch here?????
ServiceClient.GetTestBusesAsync(0, 0, TestNumber);

當通訊出現問題時, GetTestBusesCompletedEventArgs類的一部分應包含Error屬性。 測試該屬性是否不為null,如果是,則按您認為合適的方式處理異常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM