|
Re: It is safe to use Abort in HttpWebRequest?: msg#00117windows.devel.dotnet.web
Thanks Ian, can you give me any clue over how to stop the HttpWebRequest? I need to stop the HttpRequest because the timeout has expired, and I need to implement the timeout because in the asynchronous HttpRequest there isn't a implementation timeout. Now, my wrong implementation because use Abort is: //To set the timeout ThreadPool.RegisterWaitForSingleObject (result.AsyncWaitHandle, new WaitOrTimerCallback(TimeoutCallback), _httpWebRequest, _timeout, true); //To kill the request private void TimeoutCallback(object state, bool timedOut) { if (timedOut) { HttpWebRequest request = state as HttpWebRequest; if (request != null) { request.Abort(); CleanUp(); } } } -----Mensaje original----- De: Discussion of building .NET applications targeted for the Web [mailto:DOTNET-WEB@xxxxxxxxxxxxxxxxxxx] En nombre de Ian Griffiths Enviado el: miércoles, 26 de enero de 2005 12:22 Para: DOTNET-WEB@xxxxxxxxxxxxxxxxxxx Asunto: Re: [DOTNET-WEB] It is safe to use Abort in HttpWebRequest? It's never safe to abort another thread on the current CLR. The only situation in which it is safe to abort is when you are aborting your own thread. (ASP.NET sometimes does this in order to terminate the handling of a request.) The reason it's never safe to abort another thread is because you have no idea exactly where the abort exception will be thrown from. (Which is also why it *is* OK to abort the current thread - you know exactly where the ThreadAbortException will be thrown in that case.) Here's a little more detail on why it's bad: http://www.interact-sw.co.uk/iangblog/2004/11/12/cancellation There's nothing to make HttpWebRequest special in this regard - aborting that's going to be no better than aborting anything else. What are you trying to achieve? There may well be a better way... -- Ian Griffiths - DevelopMentor http://www.interact-sw.co.uk/iangblog/ > -----Original Message----- > From: Javier Martinez Álvarez > > I know that is not a good practice to use Abort to kill a thread. But What > about in HttpwebRequest? It is safe? =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Problems deploying a web application: 00117, Ivanoff, Alex |
|---|---|
| Next by Date: | Re: Problems deploying a web application: 00117, lizet peña |
| Previous by Thread: | Re: It is safe to use Abort in HttpWebRequest?i: 00117, Javier Martinez Álvarez |
| Next by Thread: | Re: It is safe to use Abort in HttpWebRequest?: 00117, Ian Griffiths |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |