Ejemplo n.º 1
0
 /// <summary>
 /// Initializes CefSharp with user-provided settings.
 /// It's important to note that Initialize and Shutdown <strong>MUST</strong> be called on your main
 /// application thread (typically the UI thread). If you call them on different
 /// threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
 /// </summary>
 /// <param name="settings">CefSharp configuration settings.</param>
 /// <returns>true if successful; otherwise, false.</returns>
 public static bool Initialize(CefSettingsBase settings)
 {
     using (settings.settings)
     {
         return(Core.Cef.Initialize(settings.settings));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes CefSharp with user-provided settings.
 /// It's important to note that Initialize/Shutdown <strong>MUST</strong> be called on your main
 /// application thread (typically the UI thread). If you call them on different
 /// threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
 /// </summary>
 /// <param name="settings">CefSharp configuration settings.</param>
 /// <param name="performDependencyCheck">Check that all relevant dependencies available, throws exception if any are missing</param>
 /// <param name="cefApp">Implement this interface to provide handler implementations. Null if you don't wish to handle these events</param>
 /// <returns>true if successful; otherwise, false.</returns>
 public static bool Initialize(CefSettingsBase settings, bool performDependencyCheck, IApp cefApp)
 {
     using (settings.settings)
     {
         return(Core.Cef.Initialize(settings.settings, performDependencyCheck, cefApp));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes CefSharp with user-provided settings.
 /// It's important to note that Initialize/Shutdown <strong>MUST</strong> be called on your main
 /// application thread (typically the UI thread). If you call them on different
 /// threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
 /// </summary>
 /// <param name="settings">CefSharp configuration settings.</param>
 /// <param name="performDependencyCheck">Check that all relevant dependencies available, throws exception if any are missing</param>
 /// <param name="browserProcessHandler">The handler for functionality specific to the browser process. Null if you don't wish to handle these events</param>
 /// <returns>true if successful; otherwise, false.</returns>
 public static bool Initialize(CefSettingsBase settings, bool performDependencyCheck, IBrowserProcessHandler browserProcessHandler)
 {
     using (settings.settings)
     {
         return(Core.Cef.Initialize(settings.settings, performDependencyCheck, browserProcessHandler));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes CefSharp with user-provided settings. This method allows you to wait for
        /// <see cref="IBrowserProcessHandler.OnContextInitialized"/> to be called before continuing.
        /// It's important to note that Initialize and Shutdown <strong>MUST</strong> be called on your main
        /// application thread (typically the UI thread). If you call them on different
        /// threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
        /// </summary>
        /// <param name="settings">CefSharp configuration settings.</param>
        /// <param name="performDependencyCheck">Check that all relevant dependencies available, throws exception if any are missing</param>
        /// <returns>returns a Task that can be awaited. true if successful; otherwise, false. If false check the log file for possible errors</returns>
        /// <remarks>
        /// If successful then the Task will be completed successfully when <see cref="IBrowserProcessHandler.OnContextInitialized"/> is called.
        /// If successful then the continuation will happen syncrionously on the CEF UI thread.
        /// </remarks>
        public static Task <bool> InitializeAsync(CefSettingsBase settings, bool performDependencyCheck = true)
        {
            var tcs     = new TaskCompletionSource <bool>();
            var handler = new InitializeAsyncBrowserProcessHandler(tcs);

            using (settings.settings)
            {
                try
                {
                    var success = Core.Cef.Initialize(settings.settings, performDependencyCheck, handler);

                    //Failed, need to check the log file
                    if (!success)
                    {
                        tcs.TrySetResult(false);
                    }
                }
                catch (Exception ex)
                {
                    tcs.TrySetException(ex);
                }
            }

            return(tcs.Task);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes CefSharp with user-provided settings. This method allows you to wait for
        /// <see cref="IBrowserProcessHandler.OnContextInitialized"/> to be called before continuing.
        /// It's important to note that Initialize and Shutdown <strong>MUST</strong> be called on your main
        /// application thread (typically the UI thread). If you call them on different
        /// threads, your application will hang. See the documentation for Cef.Shutdown() for more details.
        /// </summary>
        /// <param name="settings">CefSharp configuration settings.</param>
        /// <param name="performDependencyCheck">Check that all relevant dependencies available, throws exception if any are missing</param>
        /// <param name="browserProcessHandler">The handler for functionality specific to the browser process. Null if you don't wish to handle these events</param>
        /// <returns>returns a Task that can be awaited. true if successful; otherwise, false. If false check the log file for possible errors</returns>
        /// <remarks>
        /// If successful then the Task will be completed successfully when <see cref="IBrowserProcessHandler.OnContextInitialized"/> is called.
        /// If successful then the continuation will happen syncrionously on the CEF UI thread.
        /// </remarks>
        public static Task <bool> InitializeAsync(CefSettingsBase settings, bool performDependencyCheck = true, IBrowserProcessHandler browserProcessHandler = null)
        {
            using (settings.settings)
            {
                try
                {
                    //Ignore the result, the Task will be set in Core.Cef.Initialze
                    Core.Cef.Initialize(settings.settings, performDependencyCheck, browserProcessHandler);
                }
                catch (Exception ex)
                {
                    GlobalContextInitialized.SetException(ex);
                }
            }

            return(GlobalContextInitialized.Task);
        }