From 8d01faabe2225d641c2cd1f8b016da331eb49355 Mon Sep 17 00:00:00 2001 From: amaitland Date: Wed, 5 Feb 2020 10:06:48 +1000 Subject: [PATCH] Core - ResourceHandler free resources in Dispose instead of Cancel There is no example of Cancel in the source code and the description in the doc doesn't really provide a clear explanation of it's intended use case. See code comment for further details --- CefSharp/ResourceHandler.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CefSharp/ResourceHandler.cs b/CefSharp/ResourceHandler.cs index d0f57a874..92b44600d 100644 --- a/CefSharp/ResourceHandler.cs +++ b/CefSharp/ResourceHandler.cs @@ -219,8 +219,14 @@ namespace CefSharp void IResourceHandler.Cancel() { - Stream = null; - tempBuffer = null; + // Prior to Prior to https://bitbucket.org/chromiumembedded/cef/commits/90301bdb7fd0b32137c221f38e8785b3a8ad8aa4 + // This method was unexpectedly being called during Read (from a different thread), + // changes to the threading model were made and I haven't confirmed if this is still + // the case. + // + // The documentation for Cancel is vaigue and there aren't any examples that + // illustrage it's intended use case so for now we'll just keep things + // simple and free our resources in Dispose } bool IResourceHandler.ProcessRequest(IRequest request, ICallback callback) @@ -988,8 +994,10 @@ namespace CefSharp if (AutoDisposeStream && Stream != null) { Stream.Dispose(); - Stream = null; } + + Stream = null; + tempBuffer = null; } } }