public unsafe int BelongsToThread(CefThreadId threadId) { fixed(cef_task_runner_t *self = &this) { return(((delegate * unmanaged[Stdcall] < cef_task_runner_t *, CefThreadId, int >)belongs_to_thread)(self, threadId)); } }
public static Task RunAsync(CefThreadId threadId, Action action) { if (CefRuntime.CurrentlyOn(threadId)) { action(); return(TaskHelpers.Completed()); } else { var tcs = new TaskCompletionSource <FakeVoid>(); StartNew(threadId, () => { try { action(); tcs.SetResultAsync(default(FakeVoid)); } catch (Exception e) { tcs.SetExceptionAsync(e); } }); return(tcs.Task); } }
private void OnExecute(IntPtr self, CefThreadId threadid) { if (_action != null) { _action(); } OnExecuted(EventArgs.Empty); }
/// <summary> /// Post a task for delayed execution on the specified thread. This function may /// be called on any thread. It is an error to request a thread from the wrong /// process. /// </summary> public static bool PostTask(CefThreadId threadId, CefTask task, long delay) { if (task == null) { throw new ArgumentNullException("task"); } return(libcef.post_delayed_task(threadId, task.ToNative(), delay) != 0); }
/// <summary> /// Post a task for delayed execution on the specified thread. /// This function may be called on any thread. /// </summary> public static void PostTask(CefThreadId threadId, CefTask task, long delayMs) { var result = NativeMethods.cef_post_delayed_task((cef_thread_id_t)threadId, task.GetNativePointerAndAddRef(), delayMs) != 0; if (!result) { ThrowPostTaskError(); } }
public static TaskScheduler GetTaskScheduler(CefThreadId threadId) { CefTaskScheduler result; if (!TaskSchedulers.TryGetValue(threadId, out result)) { result = new CefTaskScheduler(threadId); TaskSchedulers.Add(threadId, result); } return(result); }
protected override void Execute(CefThreadId threadId) { try { this.d(this.state); } finally { if (this.waitHandle != null) { this.waitHandle.Set(); } } }
/// <summary> /// Executes the task on the selected CEF thread. /// </summary> /// <param name="threadId">The thread identifier.</param> /// <param name="action">The action.</param> /// <exception cref="System.ArgumentNullException">action</exception> public static void ExecuteTask(CefThreadId threadId, Action action) { if (action == null) { throw new ArgumentNullException("action"); } if (!CefRuntime.CurrentlyOn(threadId)) { CefRuntime.PostTask(threadId, new ActionTask(action)); } else { action(); } }
public static int belongs_to_thread(cef_task_runner_t *self, CefThreadId threadId) { belongs_to_thread_delegate d; var p = self->_belongs_to_thread; if (p == _p5) { d = _d5; } else { d = (belongs_to_thread_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(belongs_to_thread_delegate)); if (_p5 == IntPtr.Zero) { _d5 = d; _p5 = p; } } return(d(self, threadId)); }
/// <summary> /// Returns the <see cref="CefNetSynchronizationContextAwaiter"/> for the specified CEF thread. /// </summary> /// <param name="threadId">The CEF thread identifier.</param> /// <returns>The <see cref="CefNetSynchronizationContextAwaiter"/> for the CEF thread.</returns> public static CefNetSynchronizationContextAwaiter GetForThread(CefThreadId threadId) { CefNetSynchronizationContextAwaiter instance; _SyncRoot.EnterReadLock(); try { _Awaiters.TryGetValue(threadId, out instance); } finally { _SyncRoot.ExitReadLock(); } if (instance != null) { return(instance); } // These awaiters should have been added in the static constructor. if (threadId == CefThreadId.Renderer || threadId == CefThreadId.UI) { throw new ArgumentOutOfRangeException(nameof(threadId)); } _SyncRoot.EnterWriteLock(); try { if (!_Awaiters.TryGetValue(threadId, out instance)) { instance = new CefNetSynchronizationContextAwaiter(threadId); _Awaiters.Add(threadId, instance); } } finally { _SyncRoot.ExitWriteLock(); } return(instance); }
public static void StartNew(CefThreadId threadId, Action action) { CefRuntime.PostTask(threadId, new CefActionTask(action)); }
/// <summary> /// Returns true if this task runner is for the specified CEF thread. /// </summary> public bool BelongsToThread(CefThreadId threadId) { return cef_task_runner_t.belongs_to_thread(_self, threadId) != 0; }
public static extern int CefPostDelayedTask(CefThreadId threadid, IntPtr task, long delayMs);
/// <summary> /// Causes the calling thread to yield execution to the specified CEF thread. /// </summary> /// <param name="threadId">The CEF thread identifier to switch to.</param> /// <returns> /// An object that is notified when the switch to the CEF thread operation is finished. /// </returns> protected CefNetSynchronizationContextAwaiter SwitchToCefThread(CefThreadId threadId) { return(CefNetSynchronizationContextAwaiter.GetForThread(threadId)); }
/// <summary> /// CEF maintains multiple internal threads that are used for handling different /// types of tasks in different processes. See the cef_thread_id_t definitions in /// cef_types.h for more information. This function will return true if called on /// the specified thread. It is an error to request a thread from the wrong /// process. /// </summary> public static bool CurrentlyOn(CefThreadId threadId) { return libcef.currently_on(threadId) != 0; }
/// <summary> /// The post task. /// </summary> /// <param name="threadId"> /// The thread id. /// </param> /// <param name="action"> /// The action. /// </param> /// <param name="flag"> /// The flag. /// </param> private void PostTask(CefThreadId threadId, Action <bool> action, bool flag) { CefRuntime.PostTask(threadId, new ActionTask4(action, flag)); }
/// <summary> /// Post a task for delayed execution on the specified thread. /// This function may be called on any thread. /// </summary> public void Post(CefThreadId threadId, long delayMs) { Cef.PostTask(threadId, this, delayMs); }
/// <summary> /// Post a task for execution on the specified thread. /// This function may be called on any thread. /// </summary> public void Post(CefThreadId threadId) { Cef.PostTask(threadId, this); }
/// <summary> /// Post a task for delayed execution on the specified thread. /// This function may be called on any thread. /// </summary> public static void Post(CefThreadId threadId, Action action, long delayMs) { Cef.PostTask(threadId, new CefActionTask(action), delayMs); }
/// <summary> /// Post a task for execution on the specified thread. /// This function may be called on any thread. /// </summary> public static void Post(CefThreadId threadId, Action action) { Cef.PostTask(threadId, new CefActionTask(action)); }
/// <summary> /// Post a task for delayed execution on the specified thread. /// This function may be called on any thread. /// </summary> public static void Post(CefThreadId threadId, CefTask task, long delayMs) { Cef.PostTask(threadId, task, delayMs); }
/// <summary> /// Post a task for execution on the specified thread. /// This function may be called on any thread. /// </summary> public static void Post(CefThreadId threadId, CefTask task) { Cef.PostTask(threadId, task); }
private CefNetSynchronizationContextAwaiter(CefThreadId tid) { _threadId = tid; }
/// <summary> /// The post task. /// </summary> /// <param name="threadId"> /// The thread id. /// </param> /// <param name="action"> /// The action. /// </param> /// <param name="port"> /// The port. /// </param> /// <param name="completionCallback"> /// The completion callback. /// </param> private void PostTask(CefThreadId threadId, Action <int, Action> action, int port, Action completionCallback) { CefRuntime.PostTask(threadId, new ActionTask2(action, port, completionCallback)); }
/// <summary> /// Method that will be executed. /// </summary> /// <param name="threadId">Thread executing the call.</param> protected abstract void Execute(CefThreadId threadId);
public static extern int post_task(CefThreadId threadId, cef_task_t* task);
/// <summary> /// Returns true (1) if this task runner is for the specified CEF thread. /// </summary> public unsafe virtual bool BelongsToThread(CefThreadId threadId) { return(SafeCall(NativeInstance->BelongsToThread(threadId) != 0)); }
public CefThreadSynchronizationContext(CefThreadId threadId) { this.threadId = threadId; this.waitHandle = new AutoResetEvent(false); }
/// <summary> /// CEF maintains multiple internal threads that are used for handling /// different types of tasks. /// The UI thread creates the browser window and is used for all interaction with the WebKit rendering engine and V8 JavaScript engine /// (The UI thread will be the same as the main application thread if cef_initialize() is called with a CefSettings.multi_threaded_message_loop value of false (0).) /// The IO thread is used for handling schema and network requests. /// The FILE thread is used for the application cache and other miscellaneous activities. /// This function will return true (1) if called on the specified thread. /// </summary> public static bool CurrentlyOn(CefThreadId threadId) { return NativeMethods.cef_currently_on((cef_thread_id_t)threadId) != 0; }
/// <summary> /// Post a task for delayed execution on the specified thread. This function may /// be called on any thread. It is an error to request a thread from the wrong /// process. /// </summary> public static bool PostTask(CefThreadId threadId, CefTask task, long delay) { if (task == null) throw new ArgumentNullException("task"); return libcef.post_delayed_task(threadId, task.ToNative(), delay) != 0; }
/// <summary> /// Post a task for delayed execution on the specified thread. /// This function may be called on any thread. /// </summary> public static void PostTask(CefThreadId threadId, CefTask task, long delayMs) { var result = NativeMethods.cef_post_delayed_task((cef_thread_id_t)threadId, task.GetNativePointerAndAddRef(), delayMs) != 0; if (!result) ThrowPostTaskError(); }
public static void PostTask(CefThreadId threadId, Action action) { CefRuntime.PostTask(threadId, new ActionTask(action)); }
public static int belongs_to_thread(cef_task_runner_t* self, CefThreadId threadId) { belongs_to_thread_delegate d; var p = self->_belongs_to_thread; if (p == _p5) { d = _d5; } else { d = (belongs_to_thread_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(belongs_to_thread_delegate)); if (_p5 == IntPtr.Zero) { _d5 = d; _p5 = p; } } return d(self, threadId); }
/// <summary> /// Returns the task runner for the specified CEF thread. /// </summary> public static CefTaskRunner GetForThread(CefThreadId threadId) { return CefTaskRunner.FromNativeOrNull(cef_task_runner_t.get_for_thread(threadId)); }
public static extern cef_task_runner_t* get_for_thread(CefThreadId threadId);
public static extern int CefCurrentlyOn(CefThreadId threadid);
/// <summary> /// Returns the task runner for the specified CEF thread. /// </summary> public static CefTaskRunner GetForThread(CefThreadId threadId) { return(CefTaskRunner.Wrap(CefTaskRunner.Create, CefNativeApi.cef_task_runner_get_for_thread(threadId))); }
protected override void Execute(CefThreadId threadId) { this.action(); }
public static extern int currently_on(CefThreadId threadId);
/// <summary> /// The post task. /// </summary> /// <param name="threadId"> /// The thread id. /// </param> /// <param name="action"> /// The action. /// </param> /// <param name="address"> /// The address. /// </param> /// <param name="port"> /// The port. /// </param> /// <param name="completionCallback"> /// The completion callback. /// </param> private void PostTask(CefThreadId threadId, Action <string, int, Action> action, string address, int port, Action completionCallback) { CefRuntime.PostTask(threadId, new ActionTask1(action, address, port, completionCallback)); }
public static extern int post_delayed_task(CefThreadId threadId, cef_task_t *task, long delay_ms);
/// <summary> /// The post task. /// </summary> /// <param name="threadId"> /// The thread id. /// </param> /// <param name="action"> /// The action. /// </param> /// <param name="completionCallback"> /// The completion callback. /// </param> private void PostTask(CefThreadId threadId, Action <Action> action, Action completionCallback) { CefRuntime.PostTask(threadId, new ActionTask3(action, completionCallback)); }
public static extern int CefPostTask(CefThreadId threadid, IntPtr task);
public static extern int post_delayed_task(CefThreadId threadId, cef_task_t* task, long delay_ms);
/// <summary> /// Returns true if this task runner is for the specified CEF thread. /// </summary> public bool BelongsToThread(CefThreadId threadId) { return(cef_task_runner_t.belongs_to_thread(_self, threadId) != 0); }
public static extern cef_task_runner_t *get_for_thread(CefThreadId threadId);
public unsafe extern int BelongsToThread(CefThreadId threadId);
public static extern int post_task(CefThreadId threadId, cef_task_t *task);
public CefTaskScheduler(CefThreadId threadId) { ThreadId = threadId; }
/// <summary> /// CEF maintains multiple internal threads that are used for handling different /// types of tasks in different processes. See the cef_thread_id_t definitions in /// cef_types.h for more information. This function will return true if called on /// the specified thread. It is an error to request a thread from the wrong /// process. /// </summary> public static bool CurrentlyOn(CefThreadId threadId) { return(libcef.currently_on(threadId) != 0); }
/// <summary> /// Returns the task runner for the specified CEF thread. /// </summary> public static CefTaskRunner GetForThread(CefThreadId threadId) { return(CefTaskRunner.FromNativeOrNull(cef_task_runner_t.get_for_thread(threadId))); }
/// <summary> /// The post task. /// </summary> /// <param name="threadId"> /// The thread id. /// </param> /// <param name="action"> /// The action. /// </param> private static void PostTask(CefThreadId threadId, Action action) { CefRuntime.PostTask(threadId, new ActionTask(action)); }