DUPLICATE: How can I programmatically determine if my workstation is locked?
How can I detect (during runtime) when a Windows user has locked their
A SessionSwitch event may be your best bet for this. Check the SessionSwitchReason passed through the SessionSwitchEventArgs to find out what kind of switch it is and react appropriately.