简体   繁体   中英

Windows 7 64bit - Sleep\resume c# code

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#.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM