问题
I made a httpwebrequest in a sub. The form on my program has a start button which calls the sub. I want to add a Stop button to it to stop the httwebrequest if the user so chooses.
How would I do this?
回答1:
Call Abort on the HttpWebRequest.
BEWARE that this might cause some strange behaviour... for example: depending on how you made the request and in what state it is this might lead to a deadlock.
回答2:
You could use the HttpWebRequest.Abort()
method to stop your HTTP request.
Please see the following MSDN link for an example.
来源:https://stackoverflow.com/questions/9150738/stop-a-httpwebrequest