Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在一个新线程中调用 HttpWebRequest.GetResponse(), GetResponseStream,Read。有时,当我从单击事件中调用 Abort() 时,我的 GUI 会冻结。我应该从不同的线程调用 Abort 吗?
来自微软网站
如果在这些操作中的任何一个未完成时调用 Abort方法,Abort 方法将同步执行指定给 BeginGetRequestStream 或 BeginGetResponse 方法的回调。这可能导致潜在的死锁问题。
你有没有试过 HttpWebRequest.Close();
即使你在另一个线程中调用,abort 方法也是同步的。