Welcome Guest Search | Active Topics | Sign In | Register

EvalScript is never ready for execution. Options
Scott McGarrigle
Posted: Friday, January 13, 2017 5:31:32 PM
Rank: Newbie
Groups: Member

Joined: 5/22/2016
Posts: 2
I'm doing a simple thing, but cannot eval a script. here's the gist of it:

this.View.WebView.LoadHtml("<html><body>Welcome to Utelogy...</body></html>");

System.Threading.Thread.Sleep(4000);

this.View.WebView.EvalScript( "window.alert('Hey, It worked!'",true );

This EvalScript is working in another application all day long, but this I can figure out why it's not working. It tried QueueScripCall, but it went into la-la land. Following is the exception dump.

Thanks for your help.


Exception:
EO.WebBrowser.JSInvokeException: EvalScript failed because script context is not ready. Please use QueueScriptCall instead of EvalScript to execute JavaScript code in this case, or check CanEvalScript property before calling EvalScript.

Begin_Block_1
gAAAACHkZfs2wflOipEIaSt/85Aq4EswUNd2dFqj7iZSgr2DrWJ057Qo0HmQvjBJgos/qG/vPyyo
D/XbOq72IGR1BfZvyhEiB3WucW4pTh1p8RE/NLt5nr9ojnlIzDxhRrmA79EGLi9gdp4SFsES0kYk
5ubMBv5BDBNPM/ElRvh3wgwmEAAAALe/QSCuME5LMElIkSY+hGkwAQAAl4yIbEslDf+YbFTprGzb
vyftJHYm1F+uvjBRLKSuKOPsvC+6/trXwT7IbTF0ltovWu2BK4LtpYw7yWXXQ/bnByLo6WgSfCds
ya6OPua5JMkDK9DQSnHiAKOOVc2H7CdaSfTYBJdy5bLu/AMnjTO8wS0f+IupV56b+78wvrPXZF9a
v2YUkrRodrHkEeMvlRXJ/mdnMEwzR5h1QNP3qyPWsEh2x+54PMupVOyZY+mdvm4hnkGFOoYu13XQ
WLiRk2rhnXeuDj/8DIAqAEhfoT3wudIz9MqNL0t3TTdMBfW0Ve6uusqyy6+9i7PbIlnUGFkMlPB7
CpwUokXTkOGKiScGx70OWeGQxY6H51Pksxs17JlqWMloVR9RmVLQ4FykECJobB5yeOlm4N1U+Llv
br237Q==
End_Block_1

Begin_Block_2
gAAAAFMwZbtslMlDk29MIWuKqyOiZr+GYKCRAEAIiwQH2QemUQ9e+KjzZFGH+pTdyiB/tiKazQ1m
Pf7LkYhJ1UXMcQWcbv4SIr7X87SlMO+FtSDjJhgu7uClN0LUfGN+ECxnmzb/pP9jkjaIcnMHo3VN
0J6MRoU3CRBeZYJrIJHjQ3IlEAAAAFiAWQcWVttXQLiX8taHL2IQAAAAUwPsa9nSweR2Oud9OdXF
sg==
End_Block_2
eo_support
Posted: Saturday, January 14, 2017 8:31:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

You can not use Thread.Sleep. Try to use LoadHtmlAndWait and see if it works. The browser engine works asynchronously so the internal work must continue in order for the HTML to finish load. Thread.Sleep will block everything thus nothing happens, so immediately after Thread.Sleep finishes, the HTML is guaranteed NOT loaded. LoadHtmlAndWait on the other hand does continue process the internal work of the browser engine.

Thanks!
Scott McGarrigle
Posted: Saturday, January 14, 2017 5:13:08 PM
Rank: Newbie
Groups: Member

Joined: 5/22/2016
Posts: 2
Thanks. The Load and Wait didn't work either, but here's the deal. I was doing all this in the construction/loading of my window. Apparently during that time there was some blocking or something affecting this. Ultimately, I used the Dispatcher to perform the work I needed once the dispatcher was idle. Thanks
eo_support
Posted: Saturday, January 14, 2017 5:48:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
That makes sense. Load will never finish in constructor either. Internally the WebView relies on windows messages to work. So the window handle has to be created and message pump has to be up and running in order for everything to move ahead.


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.