Tag: 用户不活动

不活动和活动,应用程序空闲,用户不活动自动注销

经过大量的谷歌搜索和花费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); }; }