@@ -74,18 +74,14 @@ side effects on macOS.
7474On macOS running the global hook requires that the main run-loop be present. libuiohook takes care of it if the hook
7575is run on the main thread. It's also taken care of by UI frameworks since they need an event loop on the main thread
7676to run. But if you're using a global hook in a console app or a background service and want to run it on some thread
77- other than the main one then you should take care of it yourself. You can do that by P/Invoking the native
78- ` CFRunLoopRun ` function on the main thread:
79-
77+ other than the main one (e.g., ` hook.RunAsync() ` will run the hook on a different thread), then you should take care of
78+ it yourself. You can do that by P/Invoking the native ` CFRunLoopRun ` function on the main thread:
8079
8180``` csharp
8281internal static partial class CoreFoundation
8382{
8483 private const string CoreFoundationLib = " /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation" ;
8584
86- [LibraryImport (CoreFoundationLib )]
87- public static partial void CFRelease (IntPtr @ref );
88-
8985 // It's better to use a type derived from SafeHandle as the return type, but it's omitted for brevity
9086 [LibraryImport (CoreFoundationLib )]
9187 public static partial IntPtr CFRunLoopGetCurrent ();
@@ -105,7 +101,6 @@ public static void RunMainLoop(CancellationToken token)
105101 var loop = CoreFoundation .CFRunLoopGetCurrent ();
106102 token .Register (() => CoreFoundation .CFRunLoopStop (loop ));
107103 CoreFoundation .CFRunLoopRun (); // This method will block the current thread until CFRunLoopStop is called
108- CoreFoundation .CFRelease (loop ); // Ideally, this method should be called when a SafeHandle is released instead
109104 }
110105
111106// ...
0 commit comments