mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 19:54:53 +00:00
CefSharpSettings.SubprocessExitIfParentProcessClosed - only spawn task to monitor parent if command line arg present
Follow up to #2375
This commit is contained in:
@@ -20,7 +20,10 @@ namespace CefSharp.BrowserSubprocess
|
||||
int result;
|
||||
var type = args.GetArgumentValue(CefSharpArguments.SubProcessTypeArgument);
|
||||
var parentProcessId = int.Parse(args.GetArgumentValue(CefSharpArguments.HostProcessIdArgument));
|
||||
Task.Factory.StartNew(() => AwaitParentProcessExit(parentProcessId), TaskCreationOptions.LongRunning);
|
||||
if (args.HasArgument(CefSharpArguments.ExitIfParentProcessClosed))
|
||||
{
|
||||
Task.Factory.StartNew(() => AwaitParentProcessExit(parentProcessId), TaskCreationOptions.LongRunning);
|
||||
}
|
||||
|
||||
//Use our custom subProcess provides features like EvaluateJavascript
|
||||
if (type == "renderer")
|
||||
|
||||
@@ -60,6 +60,11 @@ namespace CefSharp
|
||||
commandLine->AppendArgument(StringUtils::ToNative(CefSharpArguments::WcfEnabledArgument));
|
||||
}
|
||||
|
||||
if (CefSharpSettings::SubprocessExitIfParentProcessClosed)
|
||||
{
|
||||
commandLine->AppendSwitch(StringUtils::ToNative(CefSharpArguments::ExitIfParentProcessClosed));
|
||||
}
|
||||
|
||||
//ChannelId was removed in https://bitbucket.org/chromiumembedded/cef/issues/1912/notreached-in-logchannelidandcookiestores
|
||||
//We need to know the process Id to establish WCF communication and for monitoring of parent process exit
|
||||
commandLine->AppendArgument(StringUtils::ToNative(CefSharpArguments::HostProcessIdArgument + "=" + Process::GetCurrentProcess()->Id));
|
||||
|
||||
@@ -181,6 +181,18 @@ namespace CefSharp.Example
|
||||
|
||||
settings.FocusedNodeChangedEnabled = true;
|
||||
|
||||
//Experimental option where bound async methods are queued on TaskScheduler.Default.
|
||||
//CefSharpSettings.ConcurrentTaskExecution = true;
|
||||
|
||||
//Legacy Binding Behaviour doesn't work for cross-site navigation (navigating to a different domain)
|
||||
//See issue https://github.com/cefsharp/CefSharp/issues/1203 for details
|
||||
//CefSharpSettings.LegacyJavascriptBindingEnabled = true;
|
||||
|
||||
//Exit the subprocess if the parent process happens to close
|
||||
//This is optional at the moment
|
||||
//https://github.com/cefsharp/CefSharp/pull/2375/
|
||||
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
|
||||
|
||||
//NOTE: Set this before any calls to Cef.Initialize to specify a proxy with username and password
|
||||
//One set this cannot be changed at runtime. If you need to change the proxy at runtime (dynamically) then
|
||||
//see https://github.com/cefsharp/CefSharp/wiki/General-Usage#proxy-resolution
|
||||
@@ -192,13 +204,6 @@ namespace CefSharp.Example
|
||||
}
|
||||
|
||||
Cef.AddCrossOriginWhitelistEntry(BaseUrl, "https", "cefsharp.com", false);
|
||||
|
||||
//Experimental option where bound async methods are queued on TaskScheduler.Default.
|
||||
//CefSharpSettings.ConcurrentTaskExecution = true;
|
||||
|
||||
//Legacy Binding Behaviour doesn't work for cross-site navigation (navigating to a different domain)
|
||||
//See issue https://github.com/cefsharp/CefSharp/issues/1203 for details
|
||||
//CefSharpSettings.LegacyJavascriptBindingEnabled = true;
|
||||
}
|
||||
|
||||
public static async void RegisterTestResources(IWebBrowser browser)
|
||||
|
||||
@@ -70,6 +70,13 @@ namespace CefSharp
|
||||
/// </summary>
|
||||
public static bool ShutdownOnExit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// CefSharp.BrowserSubprocess will monitor the parent process and exit if the parent process closes
|
||||
/// before the subprocess. This currently defaults to false.
|
||||
/// See https://github.com/cefsharp/CefSharp/issues/2359 for more information.
|
||||
/// </summary>
|
||||
public static bool SubprocessExitIfParentProcessClosed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The proxy options that will be used for all connections
|
||||
///
|
||||
|
||||
@@ -11,5 +11,6 @@ namespace CefSharp.Internals
|
||||
public const string CustomSchemeArgument = "--custom-scheme";
|
||||
public const string FocusedNodeChangedEnabledArgument = "--focused-node-enabled";
|
||||
public const string SubProcessTypeArgument = "--type";
|
||||
public const string ExitIfParentProcessClosed = "--CefSharpExitSub";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user