mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 19:54:53 +00:00
Add CefSharpSettings.ShutdownOnExit - all the user to disable the inbuilt call to Cef.Shutdown
(Also needs to set shutdownOnProcessExit:false when calling Cef.Initialize, or the ParentProcessExitHandler will be called to Shutdown Cef)
This commit is contained in:
@@ -68,7 +68,10 @@ namespace CefSharp.WinForms
|
||||
|
||||
static ChromiumWebBrowser()
|
||||
{
|
||||
Application.ApplicationExit += OnApplicationExit;
|
||||
if (CefSharpSettings.ShutdownOnExit)
|
||||
{
|
||||
Application.ApplicationExit += OnApplicationExit;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnApplicationExit(object sender, EventArgs e)
|
||||
|
||||
@@ -84,11 +84,14 @@ namespace CefSharp.Wpf
|
||||
|
||||
static ChromiumWebBrowser()
|
||||
{
|
||||
var app = Application.Current;
|
||||
|
||||
if (app != null)
|
||||
if (CefSharpSettings.ShutdownOnExit)
|
||||
{
|
||||
app.Exit += OnApplicationExit;
|
||||
var app = Application.Current;
|
||||
|
||||
if (app != null)
|
||||
{
|
||||
app.Exit += OnApplicationExit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,27 @@ namespace CefSharp
|
||||
{
|
||||
public static class CefSharpSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Set default values for CefSharpSettings
|
||||
/// </summary>
|
||||
static CefSharpSettings()
|
||||
{
|
||||
ShutdownOnExit = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WCF is used by JavascriptBinding
|
||||
/// Disabling effectively disables both of these features.
|
||||
/// Defaults to true
|
||||
/// </summary>
|
||||
public static bool WcfEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For the WinForms and WPF instances of ChromiumWebBrowser the relevant Application Exit event
|
||||
/// is hooked and Cef.Shutdown() called by default. Set this to false to disable this behaviour.
|
||||
/// This value needs to be set before the first instance of ChromiumWebBrowser is created as
|
||||
/// the event handlers are hooked in the static constructor for the ChromiumWebBrowser class
|
||||
/// </summary>
|
||||
public static bool ShutdownOnExit { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user