Welcome Guest Search | Active Topics | Sign In | Register

Application gets hanged when LoadUrlAndWait is used Options
arsalan younus
Posted: Friday, April 28, 2017 7:41:26 AM
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

eo_support
Posted: Friday, April 28, 2017 8:19:16 AM
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!
arsalan younus
Posted: Friday, April 28, 2017 8:29:07 AM
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?
eo_support
Posted: Friday, April 28, 2017 8:36:49 AM
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!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.