CefV8Handler Execute Method:
- Code: Select all
protected override bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception)
{
if (name == "updateCIP")
{
returnValue = CefV8Value.CreateNull();
exception = null;
if (arguments.Length == 1 && arguments[0].IsFunction)
{
var trunner = CefTaskRunner.GetForCurrentThread();
trunner.PostTask(new CipUpdateTask(CefV8Context.GetCurrentContext(),arguments[0]));
return true;
}
else
{
returnValue = CefV8Value.CreateNull();
exception = "Function Not Found!";
}
return true;
}
The CipUpdateTask is as follows:
- Code: Select all
internal class CipUpdateTask : CefTask
{
CefV8Value cb;
CefV8Context cbcontext;
internal CipUpdateTask(CefV8Context context, CefV8Value callback)
{
cb = callback;
cbcontext = context;
}
protected override void Execute()
{
CefV8Value[] args = new CefV8Value[1];
var result = signal.WaitOne(10000); ? "Signalled!" : "timeout";
args[0] = CefV8Value.CreateString(result);
cbcontext.Enter();
cb.ExecuteFunction(null, args);
cbcontext.Exit();
}
}
I had assumed that the fact i had the signal.WaitOne() in a Tasks Execute would mean that the CefBrowser would remain responsive during this call. However it simply seems to lock and the web application becomes unresponsive until the callback is fired. I need to use this long poll method to immediately update the web browser specific condition. I appreciate I could lower the timeout but this not ideal and I'm not sure why this isn't working as I'd expect without blocking.
Help really appreciated!