1

如您所见,我可以使 Web 服务超时,并且可以捕获异常。但我想捕获查询超时异常(DataServiceQueryException)。这可能吗?什么是财产?我已经搜索并找不到任何解决方案。

 try
 {
     rms.Timeout = 1; //to make the timeout
     List = rms.Query.Where(d => d.TimeStamp != null && d.TimeStamp > StartDate && d.TimeStamp <= EndDate).ToList();
 }
 catch (DataServiceQueryException queryExp)
 {
      //I want to catch the query timeout exception
 }
 catch (WebException ex)
 {
     if (ex.Status == System.Net.WebExceptionStatus.Timeout)
     {
        Console.WriteLine("Request Timeout");
        return false;
     }

}

4

0 回答 0