How to track a user's idle time in a VB.NET application

Does anyone know of a way to track a users idle time in a .Net application. A sample in VB.NET or C# would be great. We have a need to make an application either close or become partially unresponsive if a certain amount of time has passed. It needs to be application wide not just a form. We have tried the stopwatch and timer controls with marginal success. All samples we have seen so far are form specific or mention ASP.NET. We would prefer not to use API calls to do this but if nothing else can be done then perhaps that will be the solution.

The only change made was to add a new constant: Private Const WM_MOUSEMOVE As Integer = &H200. It was then placed at the beginning of the case statement. We wanted the app to be as responsive as the Windows screen saver.
Actually both solutions given were great but the one using managed code was preferred. Note: the other was on codeproject - http://www.codeproject.com/KB/system/SystemIdleTimerComponent.aspx
Thanks again

WM_MOUSEMOVE is often a controversial choice for "idle activity" routines.

It is possible for the user to be interacting with OTHER applications and simply move the mouse across your application without actually interacting with it. Should that still be considered activity for your app? Some say yes, others no. The user is obviously using the computer but the mouse activity may not be intended for your particular app...

Also, I found that on my system I was getting intermittent WM_MOUSEMOVE messages sent to my application by something occuring outside my application...even when the mouse wasn't being moved. I've never figured out what causes it so I removed it from my filter since it was causing my app to never idle time out. I'm running VB.Net 2005 Express on a WinXP Pro system.

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…

Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg).
If you're looking for how to monitor bandwidth using netflow or packet s…