Finding if system is idle

Hi,
I am working on C#.net window application.
i want some code in C#.net to know if sytem is idle.
my problem is - if user does not touch keyboard or mouse for some time, system go to sleep mood and screensaver starts.

I want to know when system go in this state, also when he/she move mouse or press any key, then do some work using c#.net code.

please help me if anyone have solution.