public int GetActiveWindow() { var hwnd = User32Wrapper.GetForegroundWindow(); if (hwnd != 0 && _hwnd != hwnd) { ActivityChanged(_hwnd, hwnd, DateTime.Now.Ticks - _ticks); _ticks = DateTime.Now.Ticks; _hwnd = hwnd; } return(hwnd); }
public void Start() { LogManager.GetInstance().Info("Activity monitor started."); _started = true; _activityStack.Load(); _hwnd = User32Wrapper.GetForegroundWindow(); _ticks = DateTime.Now.Ticks; TimerCallback refreshCallback = (obj => GetActiveWindow()); _refreshTimer = new Timer(refreshCallback, null, 0, RefreshInterval); TimerCallback sendCallback = (obj => SendData(_activityStack.GetActivities())); _sendDataTimer = new Timer(sendCallback, null, 0, SendDataInterval); }