Effectively detect app inactivity in a Windows Phone app?

How do you determine if an application has been idle for, say, 30 seconds? I know this is possible by using DispatcherTimer

and then restarting it on event PhoneApplicationPage.ManipulationCompleted

? But I am concerned that this will affect the performance of the application.

Are there any better solutions?

+3


source to share


1 answer


You are on the right track. There is no explicit "idle" notification (especially not that fast).

ManipulationCompleted may not always work for you, since another input can prevent the manipulation from starting and the user can manipulate for a very long time. I would reset the timer on any mouse input , not just ManipulationCompleted.



Depending on how accurate you want your 30 second timer to be, I would consider leaving the timer on and setting a flag for the last input. When the timer expires, check if the flag is set. This way you don't need to continuously reset the timer for every user input.

+3


source







All Articles