views:

279

answers:

1

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?

+1  A: 

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.

Jobi Joy
I don't think that we have a PreviewMouseDown in Silverlight. Please let me know if I am mistaken.
caryden
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.
Jobi Joy