How to call JS code synchronously with sendProcessMessage?

346 views
Skip to first unread message

Christian LeMoussel

unread,
Apr 17, 2015, 10:22:04 AM4/17/15
to cef...@googlegroups.com
Hi,
  1. From browser, I do sendProcessMessage with all JS information to renderer process.
  2. In renderer process (RenderProcessHandler onProcessMessageReceived method),I do TryEval on the V8Context and get the return value via out parameters
  3. In renderer process,I do sendProcessMessage back to the browser process with the JS return value

It ' Ok but it's asynchronously.

Any idea to do this synchronously?

eg in browser class, a method like ExecuteJS (pseudo code)

string ExecuteJS(string JsScript)
{
   string returnValue = sendProcessMessage with all JS information to renderer process & Receive message from
renderer process with the JS return value  
   return returnValue
}





Dmitry Azaraev

unread,
Apr 17, 2015, 7:22:25 PM4/17/15
to cef...@googlegroups.com
Hi.

Browser->Renderer IPC is always async. Chorme inside use sync IPC only in some cases from renderer->browser, and only for IO threads.
So trying to make it sync will be always bad idea ('cause if you try block thread, you probably also block one of message queue processing). It can be true sync, only if you call this method from non-CEF thread. So just make it async.


--
You received this message because you are subscribed to the Google Groups "CefGlue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefglue+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Best regards,
   Dmitry

Christian LeMoussel

unread,
Apr 26, 2015, 5:16:44 AM4/26/15
to cef...@googlegroups.com, dmitry....@gmail.com
Dmitry,

An another way  is to use Windows Communication Foundation (WCF) betwwen Browser & Render process and Task to call method.

BR,

Christian.


Reply all
Reply to author
Forward
0 new messages