Home > front end >  CefSharp LoadUrl when browser not initialized
CefSharp LoadUrl when browser not initialized

Time:02-05

I came across other CefSharp related thread where it was stated that LoadUrl() will fail if ChromiumWebBrowser wasn't yet initialized. However in my code, I call LoadUrl immediately after having created ChromiumWebBrowser instance and it works perfectly fine.

var browser = new ChromiumWebBrowser();
control.Content = browser;
browser.LoadUrl(url);

Please note I instantiate the class without address parameter.

I was thinking that maybe I should handle IsBrowserInitializedChanged event and LoadUrl there instead, but this seems to be working. What is the right approach?

CodePudding user response:

Starting in version 95 it is no longer required to wait for the browser to initialize.

Calling LoadUrl immediately after instantiating a ChromiumWebBrowser instance in WPF will internally set the initial address which as the name implies is the url initially loaded in the browser.

So your code is fine as is.

  •  Tags:  
  • Related