What is the best way to detect user inactivity in a Silverlight app?
Asked Answered
C

1

6

Does anyone know of an efficient way to detect user inactivity in a Silverlight App. The idea is that everytime a user interacts with the app in any way a timer would reload. When it expires, a "continue working.." dialog would be displays for a period and the the page would redirect to /Logout.

The rub is detecting inactivity. Thoughts?

Chanteuse answered 23/12, 2009 at 0:27 Comment(1)
Anyone figure this one out? I'm really wanting to do exactly this!Lilybelle
B
2

You may need to keep a DispatcherTimer with an elapsedtime of 100ms(Or more) and store the user activity time (DateTime.Now from a RootWindow level PreviewMouseDown) and keep checking that in the DispatcherTimer against your pre-defined inactivity time.

Update : Since PreviewEvents are not in Silverlight, you need to write your own logic around the input system of your application in your own specific way. But WPF has previewEvents so it will be easy to monitor the activity in WPF than silverlight.

Butterfly answered 23/12, 2009 at 0:33 Comment(2)
I don't think that we have a PreviewMouseDown in Silverlight. Please let me know if I am mistaken.Chanteuse
yes you are right. Silverlight doesnt support Tunnelling of events. So I am wrong on that, so you need to have your on input activity monitor by mouse click or keyboard input etc.Butterfly

© 2022 - 2024 — McMap. All rights reserved.