I'm testing a CEF3 program on Visual Studio 2013(C++) and Windows 8.1.
In the case of a thread is made with CreateThread(Win32 API), it occurs an error when getting CefV8Value in the other thread.
Isn't there any good way of processing a function asynchronously?
What you would want to do is send this over to the Browser process and do the processing there. The CEF3 Faqs covers this communication,in case you have not had need to do this before:
[...] How do I send information between the browser and render processes in CEF3?
To provide information dynamically use process messages (
CefProcessMessage) which are associated with a specific
CefBrowserinstance and are sent using the
CefBrowser::SendProcessMessage()method. [...] A message sent from the render process to the browser process will arrive in
Seems like this is quite a big deal in Adobe Brackets-Shell (a reasonably popular open source WebIDE that uses CEF3) - their guide to V8 extensions goes through this very nicely.
Whenever a native function is called,
AppShellExtensionHandler::Execute()is invoked. This code runs in the render process, so only the most trivial extension code should be executed here. For Brackets, only
getElapsedMilliseconds()is handled here. All others calls are passed to the browser process via a
AppShellExtensionHandler mentioned here is equivalent to your
AppExtensionHandler. I would highly recommend going through their code for extension handling - it's been done quite elegantly. Fair Warning: I am related to Adobe professionally, though Brackets.io is an open-source venture.
Hope this helps - Cheers!
Take a look at this post. It works like a charm. Solves all my JS to native issues and uses a structured param passing approach..and it addresses precisely the issue you are having too ... you simply have to create a user thread (Task) to handle things in background ...
I tested this myself and it works really well..unless I am missing something...
While the post describes C# it should be really straight forward to translate it to C++
©2020 All rights reserved.