internal VisitDomTask(ChromiumWebBrowser wb, Action <CfrDomDocument, CfrBrowser> callback) { this.wb = wb; this.callback = callback; this.Execute += Task_Execute; visitor = new CfrDomVisitor(); visitor.Visit += (s, e) => { if (wb.RemoteCallbacksWillInvoke) { wb.RenderThreadInvoke((MethodInvoker)(() => { callback(e.Document, wb.remoteBrowser); })); } else { callback(e.Document, wb.remoteBrowser); } }; }
internal EvaluateTask(ChromiumWebBrowser wb, string code, JSInvokeMode invokeMode, Action <CfrV8Value, CfrV8Exception> callback) { this.wb = wb; this.code = code; this.invokeMode = invokeMode; this.callback = callback; lock (tasks) tasks.Add(this); Execute += (s, e) => { if (invokeMode == JSInvokeMode.Invoke || (invokeMode == JSInvokeMode.Inherit && wb.RemoteCallbacksWillInvoke)) { wb.RenderThreadInvoke(() => Task_Execute(e)); } else { Task_Execute(e); } lock (tasks) tasks.Remove(this); }; }