How do I interrupt the HttpWebRequest (from another thread)?

I like to interrupt the HttpWebRequest when needed from another thread. Is it the right thing to do?

    public void Abort()
    {
        if (request != null)
        {
            try { request.ReadWriteTimeout = 0; } catch { }
            try { request.Timeout = 0; } catch { }
            try { request.Abort(); } catch { }
        }
    }

      

+3


source to share


1 answer


I believe it will save you some effort to put everything in one try / trick. Also take a look at this: Is it possible to interrupt a task, for example interrupt the Thread (Thread.Abort) method?



public void Abort()
{
    if (request != null)
    {
        try 
        { 
            request.ReadWriteTimeout = 0; } catch { }
            request.Timeout = 0;
            request.Abort(); 
        } catch {//Some error}
    }
}

      

0


source







All Articles