// Copyright © 2010 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.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 selfHostSubProcess = 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 functionif (selfHostSubProcess){var exitCode = CefSharp.BrowserSubprocess.SelfHost.Main(args);if (exitCode >= 0){return exitCode;}#if DEBUGif (!System.Diagnostics.Debugger.IsAttached){MessageBox.Show("When running this Example outside of Visual Studio " +"please make sure you compile in `Release` mode.", "Warning");}#endifvar settings = new CefSettings();settings.BrowserSubprocessPath = System.IO.Path.GetFullPath("CefSharp.WinForms.Example.exe");Cef.Initialize(settings);var browser = new SimpleBrowserForm();Application.Run(browser);}else{#if DEBUGif (!System.Diagnostics.Debugger.IsAttached){MessageBox.Show("When running this Example outside of Visual Studio " +"please make sure you compile in `Release` mode.", "Warning");}#endif//When multiThreadedMessageLoop = true then externalMessagePump must be set to false// To enable externalMessagePump set multiThreadedMessageLoop = false and externalMessagePump = trueconst bool multiThreadedMessageLoop = true;const bool externalMessagePump = false;var browser = new BrowserForm(multiThreadedMessageLoop);//var browser = new SimpleBrowserForm(multiThreadedMessageLoop);//var browser = new TabulationDemoForm();IBrowserProcessHandler browserProcessHandler;if (multiThreadedMessageLoop){browserProcessHandler = new BrowserProcessHandler();}else{if (externalMessagePump){//Get the current taskScheduler (must be called after the form is created)var scheduler = TaskScheduler.FromCurrentSynchronizationContext();browserProcessHandler = new ScheduleMessagePumpBrowserProcessHandler(scheduler);}else{//We'll add out WinForms timer to the components container so it's DiposedbrowserProcessHandler = new WinFormsBrowserProcessHandler(browser.Components);}}var settings = new CefSettings();settings.MultiThreadedMessageLoop = multiThreadedMessageLoop;settings.ExternalMessagePump = externalMessagePump;CefExample.Init(settings, browserProcessHandler: browserProcessHandler);//Application.Run(new MultiFormAppContext());Application.Run(browser);}return 0;}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。