I need to create a program in c# code that will sleep my machine for X mins and then resume from sleep mode. I have written a program to sleep\\hibernate my machine using PowerState.Suspend which I run on one thread and then I set a timer for x mins after which I run System.Windows.Forms.Application.Run(); to resume from sleep. I have been searching all over but alas, I am still not happy.
Does anyone have any ideas of how I can resume my laptop from a sleep state in C#
You'll have to use P/invoke to call call the CreateWaitableTimer
and SetWaitableTimer
functions.
See the MSDN documentation and this example of calling the functions from C#.
You could try this method:
http://www.yetanotherchris.me/home/2009/6/18/wake-up-from-sleep-createwaitabletimer-in-c.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.