public WindowsHook(int hookType, HandleProcMessage messageAction) { this.messageAction = messageAction; int threadId = NativeMethods.GetCurrentThreadId(); nativeCallbackLifetimeInstance = MessageCallback; hookHandle = NativeMethods.SetWindowsHookEx(hookType, nativeCallbackLifetimeInstance, IntPtr.Zero, threadId); }