aboutsummaryrefslogtreecommitdiff
path: root/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
diff options
context:
space:
mode:
Diffstat (limited to 'SocketHttpListener/Net/HttpListenerResponse.Managed.cs')
-rw-r--r--SocketHttpListener/Net/HttpListenerResponse.Managed.cs13
1 files changed, 10 insertions, 3 deletions
diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
index 9adf0d435..83fcc09ca 100644
--- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
+++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs
@@ -130,11 +130,18 @@ namespace SocketHttpListener.Net
var thisRef = (HttpListenerResponse)iar.AsyncState;
try
{
- thisRef.OutputStream.EndWrite(iar);
+ try
+ {
+ thisRef.OutputStream.EndWrite(iar);
+ }
+ finally
+ {
+ thisRef.Close(false);
+ }
}
- finally
+ catch (Exception)
{
- thisRef.Close(false);
+ // In case response was disposed during this time
}
}, this);
}