public void SetEventHandler(Action handler) { if (handler == null) { dispatch_source_set_event_handler_f(GetCheckedHandle(), IntPtr.Zero); return; } DispatchBlock.Invoke( delegate { var sc = SynchronizationContext.Current; if (sc == null) { SynchronizationContext.SetSynchronizationContext(new DispatchQueueSynchronizationContext(queue)); } try { handler(); } finally { if (sc == null) { SynchronizationContext.SetSynchronizationContext(null); } } }, block => dispatch_source_set_event_handler(GetCheckedHandle(), block)); }
public void SetCancelHandler(Action handler) { if (handler == null) { throw new ArgumentNullException("handler"); } Check(); unsafe { DispatchBlock.Invoke( delegate { var sc = SynchronizationContext.Current; if (sc == null) { SynchronizationContext.SetSynchronizationContext(new DispatchQueueSynchronizationContext(queue)); } try { handler(); } finally { if (sc == null) { SynchronizationContext.SetSynchronizationContext(null); } } }, block => dispatch_source_set_cancel_handler(handle, block)); } }
public static DispatchBlock Create(DispatchBlock block, DispatchBlockFlags flags, DispatchQualityOfService qosClass, int relative_priority) { if (block == null) { throw new ArgumentNullException(nameof(block)); } return(block.Create(flags, qosClass, relative_priority)); }
public void DispatchAfter(DispatchTime when, DispatchBlock block) { if (block == null) { throw new ArgumentNullException(nameof(block)); } dispatch_after(when.Nanoseconds, GetCheckedHandle(), block.GetCheckedHandle()); }
public void DispatchBarrierSync(DispatchBlock block) { if (block == null) { throw new ArgumentNullException(nameof(block)); } dispatch_barrier_sync(GetCheckedHandle(), block.GetCheckedHandle()); }
public void Notify(DispatchQueue queue, Action notification) { if (notification == null) { throw new ArgumentNullException(nameof(notification)); } using (var block = new DispatchBlock(notification)) Notify(queue, block); }
public void Notify(DispatchQueue queue, DispatchBlock block) { if (queue == null) { throw new ArgumentNullException(nameof(queue)); } if (block == null) { throw new ArgumentNullException(nameof(block)); } dispatch_group_notify(GetCheckedHandle(), queue.Handle, block.GetCheckedHandle()); }
public void Notify(DispatchQueue queue, DispatchBlock notification) { if (queue == null) { throw new ArgumentNullException(nameof(queue)); } if (notification == null) { throw new ArgumentNullException(nameof(notification)); } dispatch_block_notify(GetCheckedHandle(), queue.GetCheckedHandle(), notification.GetCheckedHandle()); }
public void SetRegistrationHandler(Action handler) { if (handler == null) { throw new ArgumentNullException("handler"); } DispatchBlock.Invoke( delegate { var sc = SynchronizationContext.Current; if (sc == null) { SynchronizationContext.SetSynchronizationContext(new DispatchQueueSynchronizationContext(queue)); } try { handler(); } finally { if (sc == null) { SynchronizationContext.SetSynchronizationContext(null); } } }, block => dispatch_source_set_registration_handler(GetCheckedHandle(), block)); }
public DispatchBlock(DispatchBlock dispatchBlock, DispatchBlockFlags flags, DispatchQualityOfService qosClass, int relative_priority) : base(dispatch_block_create_with_qos_class((nuint)(ulong) flags, qosClass, relative_priority, Runtime.ThrowOnNull(dispatchBlock, nameof(dispatchBlock)).GetCheckedHandle()), true) { }