From 599ad179fb0cab84fb8990ea940bba7255b98205 Mon Sep 17 00:00:00 2001 From: amaitland Date: Sat, 19 Mar 2016 07:32:47 +1000 Subject: [PATCH] Update OnContextInitialized example to dispose of requestcontext via a using statement --- CefSharp.Example/CefExample.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CefSharp.Example/CefExample.cs b/CefSharp.Example/CefExample.cs index d4a6ef89d..612414f03 100644 --- a/CefSharp.Example/CefExample.cs +++ b/CefSharp.Example/CefExample.cs @@ -145,12 +145,14 @@ namespace CefSharp.Example cookieManager.SetStoragePath("cookies", true); cookieManager.SetSupportedSchemes("custom"); - var context = Cef.GetGlobalRequestContext(); - - string errorMessage; - //You can set most preferences using a `.` notation rather than having to create a complex set of dictionaries. - //The default is true, you can change to false to disable - context.SetPreference("webkit.webprefs.plugins_enabled", true, out errorMessage); + //Dispose of context when finished - preferable not to keep a reference if possible. + using (var context = Cef.GetGlobalRequestContext()) + { + string errorMessage; + //You can set most preferences using a `.` notation rather than having to create a complex set of dictionaries. + //The default is true, you can change to false to disable + context.SetPreference("webkit.webprefs.plugins_enabled", true, out errorMessage); + } }; if (!Cef.Initialize(settings, shutdownOnProcessExit: true, performDependencyCheck: !DebuggingSubProcess))