I am developing a WinRT app. One of the requirements is that the app should have a "timed logout" feature. What this means is that on any screen, if the app has been idle for 10 mins, the app should logout and navigate back to the home screen.
The brute force way of doing this obviously would be to hook up pointer pressed events on every grid of every page and resetting the timer if any of these events is fired but I was wondering if there was a more elegant and more reliable way of doing this.
Thanks, Rajeev
I'm not aware of anything built in, but rather than attaching to
Grid
s and etc., I'd suggest you attach event handlers to the currentCoreWindow
(documentation) for the various types of events that you would need to track to determine idleness.If you did attach to a
Grid
for example, you'd find controls that usePopup
won't trigger the events. AComboBox
for example wouldn't be tracked by the event handlers.For example, you might do this:
The code relies on the
GetForCurrentThread
call (documentation) which returns the instance of the CoreWindow that is the host for all content.With the use of
DispatcherTimer
& several events you can achieve that.