Example #1
0
        public async Task InitializeCef()
        {
            var cefInitialize = new TaskCompletionSource <bool>();

            _cefThread = new Thread(new ThreadStart(() =>
            {
                // Set BrowserSubProcessPath based on app bitness at runtime
                var settings = new CefSettings();
                settings.BrowserSubprocessPath = CefAssemblyPathResolver.GetAssemblyPath("CefSharp.BrowserSubprocess.exe");

                // Make sure you set performDependencyCheck false
                Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);

                cefInitialize.SetResult(true);

                while (!_cefShutdown.Task.IsCompleted)
                {
                    Thread.Yield();
                    Thread.Sleep(100);
                }
                _cefShutdown.Task.GetAwaiter().GetResult();

                Cef.Shutdown();
            }));

            _cefThread.Start();
            await cefInitialize.Task;
        }
Example #2
0
        private static Assembly AssemblyResolve(object sender, ResolveEventArgs args)
        {
            // Source: https://github.com/cefsharp/CefSharp/issues/1714
            if (args.Name.StartsWith("CefSharp"))
            {
                string assemblyName     = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
                string archSpecificPath = CefAssemblyPathResolver.GetAssemblyPath(assemblyName);
                return(File.Exists(archSpecificPath)
                    ? Assembly.LoadFile(archSpecificPath)
                    : null);
            }

            return(null);
        }