Skip to content

Commit

Permalink
Add notes about CefLoadHandler methods/events being called on the CEF…
Browse files Browse the repository at this point in the history
… UI thread and that blocking is not advised.
  • Loading branch information
amaitland committed Oct 17, 2015
1 parent dca52f9 commit 4a66273
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
23 changes: 18 additions & 5 deletions CefSharp/ILoadHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,58 @@

namespace CefSharp
{
/// <summary>
/// Implement this interface to handle events related to browser load status.
/// The methods of this interface will be called on the CEF UI thread. Blocking in these methods
/// will likely cause your UI to become unresponsive and/or hang.
/// </summary>
public interface ILoadHandler
{
/// <summary>
/// Called when the loading state has changed. This callback will be executed twice
/// once when loading is initiated either programmatically or by user action,
/// and once when loading is terminated due to completion, cancellation of failure.
/// and once when loading is terminated due to completion, cancellation of failure.
/// This method will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
/// <param name="browserControl">The <see cref="IWebBrowser"/> control this popup is related to.</param>
/// <param name="loadingStateChangedArgs">args</param>
void OnLoadingStateChange(IWebBrowser browserControl, LoadingStateChangedEventArgs loadingStateChangedArgs);

/// <summary>
/// Called when the browser begins loading a frame.
/// The |<see cref="FrameLoadEndEventArgs.Frame"/> value will never be empty
/// The <see cref="FrameLoadEndEventArgs.Frame"/> value will never be empty
/// Check the <see cref="IFrame.IsMain"/> method to see if this frame is the main frame.
/// Multiple frames may be loading at the same time. Sub-frames may start or continue loading after the main frame load has ended.
/// This method may not be called for a particular frame if the load request for that frame fails.
/// For notification of overall browser load status use <see cref="OnLoadingStateChange"/> instead.
/// This method will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
/// <param name="browserControl">The <see cref="IWebBrowser"/> control this popup is related to.</param>
/// <param name="frameLoadStartArgs">args</param>
void OnFrameLoadStart(IWebBrowser browserControl, FrameLoadStartEventArgs frameLoadStartArgs);

/// <summary>
/// Called when the browser is done loading a frame.
/// The |<see cref="FrameLoadEndEventArgs.Frame"/> value will never be empty
/// The <see cref="FrameLoadEndEventArgs.Frame"/> value will never be empty
/// Check the <see cref="IFrame.IsMain"/> method to see if this frame is the main frame.
/// Multiple frames may be loading at the same time. Sub-frames may start or continue loading after the main frame load has ended.
/// This method will always be called for all frames irrespective of whether the request completes successfully.
/// This method will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
/// <param name="browserControl">The <see cref="IWebBrowser"/> control this popup is related to.</param>
/// <param name="frameLoadEndArgs">args</param>
void OnFrameLoadEnd(IWebBrowser browserControl, FrameLoadEndEventArgs frameLoadEndArgs);

/// <summary>
/// Called when the resource load for a navigation fails or is canceled.
/// |errorCode| is the error code number, |errorText| is the error text and
/// |failedUrl| is the URL that failed to load. See net\base\net_error_list.h
/// <see cref="LoadErrorEventArgs.ErrorCode"/> is the error code number, <see cref="LoadErrorEventArgs.ErrorText"/> is the error text and
/// <see cref="LoadErrorEventArgs.FailedUrl"/> is the URL that failed to load. See net\base\net_error_list.h
/// for complete descriptions of the error codes.
/// This method will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
/// <param name="browserControl">The <see cref="IWebBrowser"/> control this popup is related to.</param>
/// <param name="loadErrorArgs">args</param>
Expand Down
8 changes: 8 additions & 0 deletions CefSharp/IWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,33 @@ public interface IWebBrowser : IDisposable
/// time. Sub-frames may start or continue loading after the main frame load has ended. This method may not be called for a
/// particular frame if the load request for that frame fails. For notification of overall browser load status use
/// OnLoadingStateChange instead.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
event EventHandler<FrameLoadStartEventArgs> FrameLoadStart;

/// <summary>
/// Event handler that will get called when the browser is done loading a frame. Multiple frames may be loading at the same
/// time. Sub-frames may start or continue loading after the main frame load has ended. This method will always be called
/// for all frames irrespective of whether the request completes successfully.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
event EventHandler<FrameLoadEndEventArgs> FrameLoadEnd;

/// <summary>
/// Event handler that will get called when the resource load for a navigation fails or is canceled.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
event EventHandler<LoadErrorEventArgs> LoadError;

/// <summary>
/// Event handler that will get called when the Loading state has changed.
/// This event will be fired twice. Once when loading is initiated either programmatically or
/// by user action, and once when loading is terminated due to completion, cancellation of failure.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
/// </summary>
event EventHandler<LoadingStateChangedEventArgs> LoadingStateChanged;

Expand Down

0 comments on commit 4a66273

Please sign in to comment.