0

We're adding a security feature to an application that makes it "time out" in a given number of minutes, kicking the user out if they are inactive for that long. Making the timer and displaying it, etc. was all very easy as you might expect.

I then get to the part where any action on the application should reset the timer, and I can't seem to find a clean/simple way to hook into the "event pipeline" and respond to all user interaction by resetting the timer. I figured there would be somewhere/some way to do that, but so far my research has turned up nothing.

I was basically hoping for something along these lines:

Dispatcher.EventHandling += delegate (object e) 
{
  //assuming this were to come before the event went anywhere from its source
  ((RoutedEventArgs)e).Handled = false; 
  MyTimeSpan = TimeSpan.Zero; 
};

(I realize that this code doesn't check for the specific type of event, but it gets the point across)

This is not the same as the question that it was marked as duplicate of - while the answer was applicable here, the question is totally different and did not show up in searches/etc. when trying to find the answer to this question.

Yushatak
  • 741
  • 1
  • 5
  • 15
  • Not sure what you meant on user interaction. Is it all mouse / keyboard events including mouse moves that you want to catch? – pangabiMC Apr 03 '15 at 12:53
  • In this case I think this might help you: http://stackoverflow.com/questions/2105607/wpf-catch-last-window-click-anywhere – pangabiMC Apr 03 '15 at 13:06
  • That was *precisely* what I wanted - post it as an answer so I can give you credit! – Yushatak Apr 03 '15 at 13:14

0 Answers0