Performance cost of SetWinEventHook vs Polling in c#?
问题 I am developing a time tracking application, it monitors window changes and user idleness. My question is: which one costs more in terms of performance, wasting system resources: using SetWinEventHook (EVENT_SYSTEM_FOREGROUND), or setting a Timer.Tick and check if the active window title changed user32.dll GetForegroundWindow() and GetWindowText() all the time) ? For testing user idleness I already figured out that using low level mouse and keyboard hooks are more expensive than calling