/// <summary> /// Initializes a new instance of the <see cref="IdleTimeMonitor"/> class, /// using the default check interval and idle threshold. /// </summary> public IdleTimeMonitor(IProcessIdleTime idle_time_processor) { CheckIntervalInSeconds = 60; idle_threshold_ = 60; last_idle_time_ = Environment.GetSystemIdleTime(); idle_time_processor_ = idle_time_processor; sync_ = new ManualResetEvent(false); }
public void Process(IdleTimeInfo idle_time_info) { // The Send method run asynchrously and the idle_time_info could be // modified in the time between the Send operation and its execution. To // prevent this we enqueue a deep copy of the idle_time. var info = new IdleTimeInfo { LastInputTime = idle_time_info.LastInputTime, Timestamp = idle_time_info.Timestamp, MachineUpTime = idle_time_info.MachineUpTime }; mailbox_.Send(() => Send(info)); }
void Send(IdleTimeInfo idle_time_info) { try { idle_time_queue_.Enqueue(idle_time_info); while (idle_time_queue_.Pick(out idle_time_info)) { message_sender_.Send(idle_time_info); idle_time_queue_.Remove(idle_time_info.Timestamp); } } catch (Exception e) { logger_.Error( StringResources.Log_MethodThrowsException.Fmt("Send", kClassName), e); } }
void ProcessIdleTime(IdleTimeInfo idle_time) { if (idle_time.LastInputTime <= last_idle_time_.LastInputTime) { last_idle_time_.MachineUpTime = idle_time.MachineUpTime; } if (idle_time.InSeconds() > IdleThresholdInSeconds) { idle_time_processor_.Process(idle_time); last_idle_time_ = idle_time; } }
public void Send(IdleTimeInfo idle_time_info) { Console.WriteLine(idle_time_info.InSeconds()); }