Bug in HttpWebRequest/Response Dispose() implementation?
- From: "Vagif Abilov" <vagif@xxxxxxxxx>
- Date: Wed, 5 Jul 2006 21:29:47 +0200
Hello,
We have a simple piece of code that exchanges data using HTTP
request/reponse. It uses "using" statement to guarantee that the
communication channel is properly closed on completion. However, if the code
is executed multiple times, the first execution attempt works fine, but the
second attempt times out.
To verify if the channel is closed properly, we replaced that code with the
following:
HttpWebRequest request = PrepareRequest(userVerificationData,
schufaRequestType, null);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string requestID = response.Headers["RequestID"];
try
{
// Do something
}
finally
{
request = null;
response = null;
GC.Collect();
}
Then suddently everything worked! But the difference is that now we call
expensive garbage collection which of course kills the performance.
Why using Dispose method does not do the same? Isn't it the purpose of
IDisposable interface?
Vagif Abilov
Oslo Norway
.
- Follow-Ups:
- Re: Bug in HttpWebRequest/Response Dispose() implementation?
- From: Barry Kelly
- Re: Bug in HttpWebRequest/Response Dispose() implementation?
- From: Jon Skeet [C# MVP]
- Re: Bug in HttpWebRequest/Response Dispose() implementation?
- Prev by Date: Re: Fixed string concatenation
- Next by Date: Re: Bug in HttpWebRequest/Response Dispose() implementation?
- Previous by thread: Fixed string concatenation
- Next by thread: Re: Bug in HttpWebRequest/Response Dispose() implementation?
- Index(es):
Relevant Pages
|
Loading