![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
|
Why using Dispose method does not do the same? Isn't it the purpose of IDisposable interface? |
#3
| |||
| |||
|
|
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: |

#4
| |||
| |||
|
|
Vagif Abilov <vagif (AT) online (DOT) no> wrote: 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. snip Why using Dispose method does not do the same? Isn't it the purpose of IDisposable interface? Yes. Could you show us the code that doesn't work, preferrably as a short but complete program? -- Jon Skeet - <skeet (AT) pobox (DOT) com http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
#5
| |||
| |||
|
|
"Vagif Abilov" <vagif (AT) online (DOT) no> wrote: 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: I'm not sure I understand - can you show us the code that didn't work, rather than the code that did? ![]() -- Barry -- http://barrkel.blogspot.com/ |
#6
| |||
| |||
|
|
I am not in the office right now, but I guess the original code looked like this: HttpWebRequest request = PrepareRequest(...); using(HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { ... do something with response } HttpWebRequest is not disposable, so we applied "using" pattern to HttpWebResponse object only. While searching for the source of the problem, I found couple of documents: http://dturini.blogspot.com/2004/06/...with-some.html http://support.microsoft.com/?kbid=831138 Looks like there .NET 1.1 had a problem with release of unmanaged resources allocated by HttpResponse. Does .NET 2.0 has the same problem? |
#7
| |||
| |||
|
|
Vagif Abilov <vagif (AT) online (DOT) no> wrote: I am not in the office right now, but I guess the original code looked like this: HttpWebRequest request = PrepareRequest(...); using(HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { ... do something with response } HttpWebRequest is not disposable, so we applied "using" pattern to HttpWebResponse object only. While searching for the source of the problem, I found couple of documents: http://dturini.blogspot.com/2004/06/...with-some.html http://support.microsoft.com/?kbid=831138 Looks like there .NET 1.1 had a problem with release of unmanaged resources allocated by HttpResponse. Does .NET 2.0 has the same problem? Hmm. Glad you've found it. I *suspect* that .NET 2.0 doesn't have the same problem, given that it was fixed against 1.1 in the hotfix. I wouldn't like to say for sure though. -- Jon Skeet - <skeet (AT) pobox (DOT) com http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |