caryden
caryden

Reputation: 7874

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

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?

Upvotes: 6

Views: 1229

Answers (1)

Jobi Joy
Jobi Joy

Reputation: 50038

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.

Upvotes: 2

Related Questions