Delaying an action for a period of time
so that when you move your mouse to a designated corner of your desktop, the screensaver comes on...
When the mouse gets there, set a boolean and a timer. Make any mouse action clear the boolean.
Only when the timer fires and your flag is still there, proceed.
In other words, use a little state machine.
Here is pseudo code
var CurrentMouse = ...; // Get mouse coordinates. ThreadPool.QueueUserWorkItem( (s) => { Thread.Sleep(500); // Half a second // if (Mouse did not move) // Launch Screen Saver });
EDIT:Note this doesn't speak to invoking back to gui layer or thread locking. See the inspiration for this situation on my blog article entitled C# MultiThreading Using ThreadPool, Anonymous Delegates and Locks which does show proper locking.