logo       

Re: It is safe to use Abort in HttpWebRequest?: msg#00112

windows.devel.dotnet.web

Subject: Re: It is safe to use Abort in HttpWebRequest?

I want to finish the asynchronous request because a timeout is completed

-----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>
Google Custom Search

News | FAQ | advertise