Files
cefsharp/CefSharp.WinForms.Example/Program.cs
T
amaitland 366d3a898c WinForms/Wpf/OffScreen - Create specific CefSettings class for each version
- This is a breaking change as there is no common `CefSharp.CefSettings`, there is no `CefSharp.Wpf.CefSettings`, `CefSharp.WinForms.CefSettings` and `CefSharp.OffScreen.CefSettings`
 - Cef.Initialize has been removed, the `ChromiumWebBrowser` constructor will call the `Cef.Initialize` with the defaults for your flavour
 - CefSettings.FocusedNodeChangedEnabled has been moved to CefSharpSettings.FocusedNodeChangedEnabled

Resolves #2477
2018-08-02 10:48:42 +10:00

95 lines
3.2 KiB
C#

// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp.Example;
using CefSharp.Example.Handlers;
using CefSharp.WinForms.Example.Handlers;
using CefSharp.WinForms.Example.Minimal;
namespace CefSharp.WinForms.Example
{
public class Program
{
[STAThread]
public static int Main(string[] args)
{
const bool simpleSubProcess = false;
Cef.EnableHighDPISupport();
//NOTE: Using a simple sub processes uses your existing application executable to spawn instances of the sub process.
//Features like JSB, EvaluateScriptAsync, custom schemes require the CefSharp.BrowserSubprocess to function
if (simpleSubProcess)
{
var exitCode = Cef.ExecuteProcess();
if(exitCode >= 0)
{
return exitCode;
}
#if DEBUG
if (!System.Diagnostics.Debugger.IsAttached)
{
MessageBox.Show("When running this Example outside of Visual Studio" +
"please make sure you compile in `Release` mode.", "Warning");
}
#endif
var settings = new CefSettings();
settings.BrowserSubprocessPath = "CefSharp.WinForms.Example.exe";
Cef.Initialize(settings);
var browser = new SimpleBrowserForm();
Application.Run(browser);
}
else
{
#if DEBUG
if (!System.Diagnostics.Debugger.IsAttached)
{
MessageBox.Show("When running this Example outside of Visual Studio" +
"please make sure you compile in `Release` mode.", "Warning");
}
#endif
const bool multiThreadedMessageLoop = true;
var browser = new BrowserForm(multiThreadedMessageLoop);
//var browser = new SimpleBrowserForm();
//var browser = new TabulationDemoForm();
IBrowserProcessHandler browserProcessHandler;
if(multiThreadedMessageLoop)
{
browserProcessHandler = new BrowserProcessHandler();
}
else
{
//Get the current taskScheduler (must be called after the form is created)
var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
browserProcessHandler = new WinFormsBrowserProcessHandler(scheduler);
}
var settings = new CefSettings();
settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;
settings.ExternalMessagePump = !multiThreadedMessageLoop;
CefExample.Init(settings, browserProcessHandler: browserProcessHandler);
Application.Run(browser);
}
return 0;
}
}
}