我的应用程序每隔几秒查询我的服务器以进行更新。在HttpWebRequest.Abort下请求取消的异常
离开它运行了大约3天后,我观察到应用程序崩溃了以下堆栈跟踪。
正如您所知,在工作线程中获取异常时,无法捕获该异常,因此我的应用程序崩溃了。
System.Net.WebException: The request was canceled
System.Net.ServicePointManager.FindServicePoint(Uri address, IWebProxy proxy, ProxyChain& chain, HttpAbortDelegate& abortDelegate, Int32& abortState)
System.Net.HttpWebRequest.FindServicePoint(Boolean forceFind)
System.Net.AuthenticationState.PrepareState(HttpWebRequest httpWebRequest)
System.Net.AuthenticationState.ClearSession(HttpWebRequest httpWebRequest)
System.Net.HttpWebRequest.ClearAuthenticatedConnectionResources()
System.Net.HttpWebRequest.Abort(Exception exception, Int32 abortState)
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
System.Threading.ThreadPoolWorkQueue.Dispatch()
我在网上看到了许多类似的线程。但所有拥有同样筹码的人都没有得到任何帮助。
我也看到很多人建议设置我的HttpWebRequest
的属性KeepAlive=false
,但是,这可能会伤害我的表现,并且是不可接受的。