|
Rank: Newbie Groups: Member
Joined: 4/28/2017 Posts: 4
|
Hi,
When I call LoadUrlAndWait, My application gets hanged.
My Code
var webBrowser = new EO.WinForm.WebControl(); webBrowser.Dock = DockStyle.Fill; var webView = new EO.WebBrowser.WebView(); webBrowser.WebView = webView; webView.LoadUrlAndWait(url); webView.NewWindow += webview1_NewWindow; this.Controls.Add(webBrowser);
Does not come back from the method, it keeps loading. That line of code is marked red.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
This can happen if you are calling it before your window handle is created (such as inside your constructor). The page will not be loaded until all the window handle has been created. However Form can not continue on to create the handle until your code returns from the constructor. This forms a deadlock. Move your LoadUrlAndWait to somewhere else such as a button click handler, or change it from LoadUrlAndWait to LoadUrl should resolve the issue for you.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/28/2017 Posts: 4
|
I used LoadUrl(url).WaitOne(5000), It keeps waiting for 5 seconds even if page is loaded in 2 seconds. Is this supposed to work like that?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Here are the basic rules:
1. Nothing will happen until all window handles are created. This is what caused your original issue; 2. After all window handles are created, WaitOne will not return until the main page finishes loading. This is usually when the page's window.onload JavaScript event is fired; 3. If the main page relies on other non-asynchronous resource, for example, if your page reference a JavaScript file, then it will until those resources are fully loaded; 4. If your JavaScript file has any global code, those code will run before WaitOne will return;
All the above step can cause WaitOne not to return, even though visually it can appear that the page has already been loaded --- but in fact it has not been fully loaded due to one of the above scenario.
Thanks!
|
|