|
Re: It is safe to use Abort in HttpWebRequest?: msg#00122windows.devel.dotnet.web
A million of thanks -----Mensaje original----- De: Discussion of building .NET applications targeted for the Web [mailto:DOTNET-WEB@xxxxxxxxxxxxxxxxxxx] En nombre de Ian Griffiths Enviado el: jueves, 27 de enero de 2005 10:55 Para: DOTNET-WEB@xxxxxxxxxxxxxxxxxxx Asunto: Re: [DOTNET-WEB] It is safe to use Abort in HttpWebRequest? You can call the Abort method on HttpWebRequest. This is completely different from aborting a thread - they are two different operations. (They just happen to use the same method name. For those of you who follow the whole misnamed 'latent typing' discussion, this is precisely the kind of reason I dislike the idea of relying on names alone to identify semantics...) I thought you were talking about Thread.Abort, since your original question was: > I know that is not a good practice to use Abort to kill a > thread. But What about in HttpwebRequest? It is safe? The way I read this was "Is it OK to use Thread.Abort in conjunction with HttpWebRequest?" But now I've seen your code, I realise this is not what you meant. Let me clarify my answer: It's not OK to use Abort to kill a thread as a way of stopping an HttpWebRequest. It IS OK to use the HttpWebRequest.Abort method - this is not the same thing at all as using Abort to kill a thread. I hadn't realised you were talking about HttpWebRequest.Abort here, because you started off by asking about aborting threads, something which is wholly unrelated to HttpWebRequest.Abort. Sorry about that. Your code looks OK to me. -- Ian Griffiths - DevelopMentor http://www.interact-sw.co.uk/iangblog/ > -----Original Message----- > From: Javier Martinez Álvarez > > 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(); > } > } > } =================================== 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: It is safe to use Abort in HttpWebRequest?: 00122, Ian Griffiths |
|---|---|
| Next by Date: | Security/Permission issue with OWC 11.0 on a Windows 2003 server: 00122, Nicholas Palmer |
| Previous by Thread: | Re: It is safe to use Abort in HttpWebRequest?i: 00122, Ian Griffiths |
| Next by Thread: | Problems deploying a web application: 00122, lizet peña |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |