none
Wake up computer from sleep RRS feed

  • Question

  • I've written a simple application that simulates typical user activity. Among other, it simulates user inactivity (lunch break or AFK).
    When user is inactive, computer goes to sleep.
    My problem is that I cannot wake up computer from sleep. I've tried several code examples, but none of them work. All are pretty the same, using CreateWaitableTimer and SetWaitableTimer functions. Comments on some of the examples are that they are actually working, but, unfortunately, not at my computer.

    I'm running Windows 7 on Lenovo X61 laptop.

    Can somebody try application found on this page:
    http://www.mischel.com/pubs/waitabletimer.zip
    There are multiple projects inside. Set "wakeup" as startup project.

    It's explained here:
    http://www.devsource.com/c/a/Languages/Waitable-Timers-in-NET-CSharp/

    When i run it, problem is that computer doesn't go to sleep, like it's blocking it or something, maybe cause it's waiting for the thread. I've tried creating another thread, but then computer goes to sleep and doesn't wake up.

    I've thoroughly studied Power Managment in MSDN Library and I can't figure out why the code isn't working.
    http://msdn.microsoft.com/en-us/library/aa373235(VS.85).aspx

    Thank you in advance and sry for my bad english :)
    Friday, October 23, 2009 11:16 AM

Answers

  • Using the Wakeup project, it successfully brought my computer out of hibernation.  I closed the lid and put it into hibernate and 1 minute later it came out of hibernate and showed me the login screen.

    OS:  Vista
    Hardware:  Macbook pro


    If there is anything else you want to know about my machine or anything I'll be glad to tell you.

    Good coding involves knowing one's logical limits and expanding them as necessary.
    • Marked as answer by Bin-ze Zhao Wednesday, October 28, 2009 6:34 AM
    Sunday, October 25, 2009 3:22 PM

All replies

  • Are you sure your program can run when computer is at sleep?

    Thanks,
    Viral.
    Friday, October 23, 2009 12:52 PM
  • I think that the meaning of the WaitableTimer is that he informs kernel to wake up after some time. I think program doesn't need to execute after setting the timer.

    In my code, i do something like this.

    SetTimer();
    PutComputerToSleep();

    Friday, October 23, 2009 2:20 PM
  • Review a working version and compare it to yours.

    Good coding involves knowing one's logical limits and expanding them as necessary.
    Friday, October 23, 2009 2:52 PM
  • This version doesn't work on my computer...so I'm asking does it work on yours? If does, then it's problem in computer settings, not in application :)
    Saturday, October 24, 2009 1:16 PM
  • Using the Wakeup project, it successfully brought my computer out of hibernation.  I closed the lid and put it into hibernate and 1 minute later it came out of hibernate and showed me the login screen.

    OS:  Vista
    Hardware:  Macbook pro


    If there is anything else you want to know about my machine or anything I'll be glad to tell you.

    Good coding involves knowing one's logical limits and expanding them as necessary.
    • Marked as answer by Bin-ze Zhao Wednesday, October 28, 2009 6:34 AM
    Sunday, October 25, 2009 3:22 PM
  • I've tried it on another computer and it successfully woke up from sleep.

    EDIT: But when i change my power settings on computer, for example, make it sleep after 1 minute. In code, I set timer on 2 minutes, computer never goes to sleep. Can someone try that?
    Sunday, October 25, 2009 9:05 PM