Im trying to render render a browser in side my monogame project, for drawing some interface & stuff. I've done this in the past with older versions of awesomium with no problems. But i can't figure out how to properbly initialize awesomium in this new version, I get an error no matter how i try to go about it. As i understand it i need to call WebCore.Run() once, instead of WebCore.Update(), but i get varius exceptions from that method.
Here are the steps that i've followed so far:
- Install Awesomium 1.7.4.2
- Refrenced
\1.7.4.2\wrappers\Awesomium.NET\Assemblies\Packed\Awesomium.Core.dll
in my project
Here is some of my attempts:
WebCore.Initialize(new WebConfig());
WebCore.Run();
//Error: Starting an update loop on a thread with an existing message loop, is not supported.
WebCore.Initialized += (sender, e) =>
{
WebCore.Run();
};
WebCore.Initialize(new WebConfig());
WebView WebView = WebCore.CreateWebView(500, 400);
//Error: Starting an update loop on a thread with an existing message loop, is not supported.
WebCore.Initialize(new WebConfig());
WebView WebView = WebCore.CreateWebView(500, 400);
WebView.Source = new Uri("http://www.google.com");
WebView.DocumentReady += (sender, e) =>
{
JSObject js = WebView.CreateGlobalJavascriptObject("w");
};
// No errors, but DocumentReady is never fired..
I have also managed to get NullRefrence errors, and if i wait Thread.Sleep(400) before calling WebCore.Run(), it just enters the WebCore.Run() and never completes that line.
How do i set this up? Can't find any examples anywhere. All the examples online still tells you to use Update wich is Obsolete
I have just got this working, you have to create a new thread, then call Run, then listen for an event to be raised by WebCore which will have created a new SynchronizationContext by then. You then want to keep a reference to that context on your main thread...
... you can then call all your WebView methods using that SynchronizationContext ...
I will tidy this up with a future edit, but to get you guys started, here is my component...