locked
How to know the user's interaction programmatically using C# in my Windows Store App ?

    Question

  • Hi,

    Am developing a Windows Store App using C#/XAML. My app uses a login for users. I want to implement a feature i.e. logout of application automatically and redirect to Login Page after 5 minutes. This should be happen if user is inactive for 5 min i.e. when there is no interaction from user( Keyboard, mouse, gestures, etc).

    Suggestions please.

    Appreciate your Help !!

    Thanks,

    Bhaskar

    Wednesday, July 2, 2014 9:24 PM

Answers

  • Hi Bhaskar,

    You might want to consider the following:

    1. Create a static class timer. One option is to use the System.Diagnostics.Stopwatch class
    2. Handle the CoreWindow's PointerMoved, PointerPressed, and KeyDown events. These events handle all types of pointers (mouse, touch, pen) and will occur whenever the user moves, taps, clicks, or presses a key anywhere on the screen because they are CoreWindow events.
    3. In the event handlers for these events, reset the timer for the Stopwatch by calling Stopwatch.Reset() to indicate that there was some user interaction
    4. Create an async method to check the timer's time every minute or so, and if the timer's time is greater than or equal to five minutes (or whatever the value is), log the user out

    There could be a better solution, but this is what comes to mind. I hope that helps!

    Wednesday, July 2, 2014 10:01 PM

All replies

  • Hi Bhaskar,

    You might want to consider the following:

    1. Create a static class timer. One option is to use the System.Diagnostics.Stopwatch class
    2. Handle the CoreWindow's PointerMoved, PointerPressed, and KeyDown events. These events handle all types of pointers (mouse, touch, pen) and will occur whenever the user moves, taps, clicks, or presses a key anywhere on the screen because they are CoreWindow events.
    3. In the event handlers for these events, reset the timer for the Stopwatch by calling Stopwatch.Reset() to indicate that there was some user interaction
    4. Create an async method to check the timer's time every minute or so, and if the timer's time is greater than or equal to five minutes (or whatever the value is), log the user out

    There could be a better solution, but this is what comes to mind. I hope that helps!

    Wednesday, July 2, 2014 10:01 PM
  • Thank you Alexander Deeb,

    It helped me..

    Thursday, July 3, 2014 4:10 PM