private void CefInitialize() { if (!Cef.IsInitialized) { var isDefault = AppDomain.CurrentDomain.IsDefaultAppDomain(); if (!isDefault) { throw new Exception(@"Add <add key=""xunit.appDomain"" value=""denied""/> to your app.config to disable appdomains"); } Cef.EnableWaitForBrowsersToClose(); CefSharpSettings.ShutdownOnExit = false; var settings = new CefSettings(); settings.RegisterScheme(new CefCustomScheme { SchemeName = "https", SchemeHandlerFactory = new CefSharpSchemeHandlerFactory(), DomainName = CefExample.ExampleDomain }); //The location where cache data will be stored on disk. If empty an in-memory cache will be used for some features and a temporary disk cache for others. //HTML5 databases such as localStorage will only persist across sessions if a cache path is specified. settings.CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests\\Cache"); settings.RootCachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Tests"); Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null); } }
public static int Main(string[] args) { Console.WriteLine("This example application will load {0}, take a screenshot, and save it to your desktop.", TestUrl); Console.WriteLine("You may see a lot of Chromium debugging output, please wait..."); Console.WriteLine(); Cef.EnableWaitForBrowsersToClose(); // You need to replace this with your own call to Cef.Initialize(); CefExample.Init(new CefSettings(), browserProcessHandler: new BrowserProcessHandler()); MainAsync("cache\\path1", 1.0); //Demo showing Zoom Level of 3.0 //Using seperate request contexts allows the urls from the same domain to have independent zoom levels //otherwise they would be the same - default behaviour of Chromium //MainAsync("cache\\path2", 3.0); // We have to wait for something, otherwise the process will exit too soon. Console.ReadKey(); //Wait until the browser has finished closing (which by default happens on a different thread). //Cef.EnableWaitForBrowsersToClose(); must be called before Cef.Initialize to enable this feature //See https://github.com/cefsharp/CefSharp/issues/3047 for details Cef.WaitForBrowsersToClose(); // Clean up Chromium objects. You need to call this in your application otherwise // you will get a crash when closing. Cef.Shutdown(); //Success return(0); }
static void Main(string[] args) { Cef.EnableWaitForBrowsersToClose(); CefSettings s = new CefSettings(); Cef.WaitForBrowsersToClose(); Cef.Initialize(s, performDependencyCheck: true, browserProcessHandler: null); bool kontrol = InternetKontrol(); if (kontrol != true) { Console.WriteLine("İnternet bağlantınızı kontrol ediniz."); } ChromiumWebBrowser br = new ChromiumWebBrowser(); br.LoadHtml(url); don: if (br.IsLoading) { Console.WriteLine("Yüklendi!"); } else { goto don; } Console.ReadKey(); }
public static int Main(string[] args) { Console.WriteLine("This example application will load {0}, take a screenshot, and save it to your desktop.", TestUrlOne); Console.WriteLine("You may see a lot of Chromium debugging output, please wait..."); Console.WriteLine(); //Console app doesn't have a message loop which we need as Cef.Initialize/Cef.Shutdown must be called on the same //thread. We use a super simple SynchronizationContext implementation from //https://devblogs.microsoft.com/pfxteam/await-synchronizationcontext-and-console-apps/ //Continuations will happen on the main thread //The Nito.AsyncEx.Context Nuget package has a more advanced implementation //https://github.com/StephenCleary/AsyncEx/blob/8a73d0467d40ca41f9f9cf827c7a35702243abb8/doc/AsyncContext.md#console-example-using-asynccontext AsyncContext.Run(async delegate { Cef.EnableWaitForBrowsersToClose(); var settings = new CefSettings(); //The location where cache data will be stored on disk. If empty an in-memory cache will be used for some features and a temporary disk cache for others. //HTML5 databases such as localStorage will only persist across sessions if a cache path is specified. settings.CachePath = Path.GetFullPath("cache"); var success = await Cef.InitializeAsync(settings); if (!success) { return; } var t1 = MainAsync(TestUrlOne, TestUrlTwo, "cache\\path1", 1.0); //Demo showing Zoom Level of 2.0 //Using seperate request contexts allows the urls from the same domain to have independent zoom levels //otherwise they would be the same - default behaviour of Chromium var t2 = MainAsync(TestUrlThree, TestUrlFour, "cache\\path2", 2.0); await Task.WhenAll(t1, t2); Console.WriteLine("Image viewer launched. Press any key to exit."); // Wait for user input Console.ReadKey(); //Wait until the browser has finished closing (which by default happens on a different thread). //Cef.EnableWaitForBrowsersToClose(); must be called before Cef.Initialize to enable this feature //See https://github.com/cefsharp/CefSharp/issues/3047 for details Cef.WaitForBrowsersToClose(); // Clean up Chromium objects. You need to call this in your application otherwise // you will get a crash when closing. Cef.Shutdown(); }); //Success return(0); }
public static void Init(CefConfiguration cefConfiguration) { Cef.EnableWaitForBrowsersToClose(); InitInternal(cefConfiguration); var requestContextSettings = new RequestContextSettings { CachePath = cefConfiguration.CachePathRequest }; s_requestContext = new RequestContext(requestContextSettings); }
static ChromiumElementFormatter() { Cef.EnableWaitForBrowsersToClose(); var settings = new CefSettings() { CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"), IgnoreCertificateErrors = true, CookieableSchemesExcludeDefaults = true, }; CefSharpSettings.ShutdownOnExit = true; settings.CefCommandLineArgs.Add("no-proxy-server", "1"); settings.CefCommandLineArgs.Add("disable-extensions", "1"); Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); }