【发布时间】:2014-10-20 09:49:43
【问题描述】:
经过大量谷歌搜索并花费 4 小时后,我想这是查找非活动用户和锁定屏幕的最佳方法。
public MainWindow()
{
InitializeComponent();
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(10) };
timer.Tick += delegate
{
timer.Stop();
MessageBox.Show("Logoff trigger");
timer.Start();
};
timer.Start();
InputManager.Current.PostProcessInput += delegate(object s, ProcessInputEventArgs r)
{
if (r.StagingItem.Input is MouseButtonEventArgs || r.StagingItem.Input is KeyEventArgs)
timer.Interval = TimeSpan.FromSeconds(10);
};
}
【问题讨论】:
-
你的问题是什么?
-
您可以在codereview.stackexchange.com进行代码审查
-
自我回答会更好。不要把答案放在问题中:)
标签: c# wpf logout user-inactivity