示例#1
0
        /// <summary>
        /// The warn user on load.
        /// </summary>
        /// <returns>
        /// The list of temporary files generated
        /// </returns>
        private static List <string> WarnUserOnLoad()
        {
            var tempFiles = new List <string>();

            try
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                var startTempFile = LaunchStartPage();
                tempFiles.Add(startTempFile);

                CefLoader.Load();

                stopwatch.Stop();
                var competedTempFile = LaunchCompletedPage($"Time elapsed: {stopwatch.Elapsed}.");

                if (competedTempFile != null)
                {
                    tempFiles.Add(competedTempFile);
                }

                Thread.Sleep(TimeSpan.FromSeconds(2));
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                var onErrorTempFile = LaunchErrorPage(ex);
                tempFiles.Add(onErrorTempFile);
                Environment.Exit(0);
            }

            return(tempFiles);
        }
示例#2
0
        /// <summary>
        /// The load.
        /// </summary>
        /// <param name="config">
        /// The config.
        /// </param>
        /// <returns>
        /// The list of temporary files generated
        /// </returns>
        public static List <string> Load(ChromelyConfiguration config)
        {
            try
            {
                var platform = CefRuntime.Platform;
                var version  = CefRuntime.ChromeVersion;
                Log.Info($"Running {platform} chromium {version}");

                try
                {
                    CefRuntime.Load();
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    if (config.LoadCefBinariesIfNotFound)
                    {
                        if (config.SilentCefBinariesLoading)
                        {
                            CefLoader.Load();
                        }
                        else
                        {
                            return(WarnUserOnLoad());
                        }
                    }
                    else
                    {
                        Environment.Exit(0);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                Environment.Exit(0);
            }

            return(null);
        }