public void StartWatching() { _checkProcess.RunWorkerAsync(); _handler = WinEventProc; _hook = WinAPIHelper.SetWinEventHook(3, 23, IntPtr.Zero, _handler, 0, 0, 0); // first args is EVENT_SYSTEM_FOREGROUND, last argument is WINEVENT_OUTOFCONTEXT }