public void StopBatteryListeners() { if (powerSourceNotification != null) { CFRunLoop.Current.RemoveSource(powerSourceNotification, CFRunLoop.ModeDefault); powerSourceNotification = null; } }
public void StartWatchingMediaKeys() { StopWatchingMediaKeys(); var sysMask = (CGEventMask)NX_SYSDEFINED; eventPort = CreateTap(CGEventTapLocation.Session, CGEventTapPlacement.HeadInsert, CGEventTapOptions.Default, 16384, tapEventCallback, this.Handle); eventPortSource = eventPort.CreateRunLoopSource(); Task.Run(() => { eventTapThread(); }); ShouldInterceptMediaKeyEvents = true; }
public MouseMonitor() { tapPort = CGEvent.CreateTap( CGEventTapLocation.Session, CGEventTapPlacement.TailAppend, CGEventTapOptions.ListenOnly, CGEventMask.LeftMouseUp | CGEventMask.MouseMoved, eventTapCallback = new CGEvent.CGEventTapCallback(HandleEventTap), IntPtr.Zero); runLoopSource = tapPort.CreateRunLoopSource(); CFRunLoop.Current.AddSource(runLoopSource, CFRunLoop.ModeDefault); }
void Dispose(bool disposing) { if (runLoopSource != null) { CFRunLoop.Current.RemoveSource(runLoopSource, CFRunLoop.ModeDefault); runLoopSource.Dispose(); runLoopSource = null; } if (tapPort != null) { tapPort.Dispose(); tapPort = null; } if (eventTapCallback != null) { eventTapCallback = null; } }
public void StopWatchingMediaKeys() { if (tapThread != null) { tapThread.Stop(); tapThread = null; } if (eventPort != null) { eventPort.Invalidate(); eventPort.Dispose(); eventPort = null; } if (eventPortSource != null) { eventPortSource.Invalidate(); eventPortSource.Dispose(); eventPortSource = null; } }
public WrappedNSInputStream(Stream inputStream) { status = NSStreamStatus.NotOpen; stream = inputStream; source = new CFRunLoopSource(Handle); }
public void StartBatteryListeners() { powerSourceNotification = IOKit.CreatePowerSourceNotification(PowerSourceNotification); CFRunLoop.Current.AddSource(powerSourceNotification, CFRunLoop.ModeDefault); }