0

Can any one tell how to determine the time at which the windows pc is waked up from sleep? using C#.

I know how to get the time when the computer is powered on.

namas
  • 9
  • 4
  • 1
    Please visit this topic: http://stackoverflow.com/questions/18206183/event-to-detect-system-wake-up-from-sleep-in-c-sharp – Badro Niaimi Apr 07 '16 at 16:09
  • You could [inspect the System event log](https://msdn.microsoft.com/en-us/library/k6b9a7h8%28v=vs.90%29.aspx). My Windows 7 PC logs an event from source Power-Troubleshooter when the system resumes from suspend mode. – Axel Kemper Apr 07 '16 at 16:14
  • Also see http://stackoverflow.com/a/10854355/1198986 – libertylocked Apr 07 '16 at 16:26
  • To everyone saying "visit this topic" or likewise, please click the flag link under the question and mark this question as a duplicate of the other. – Heretic Monkey Nov 21 '16 at 22:27

1 Answers1

0

You can visit this site to detect when the pc wakes up or sleeps Also you can use the Stopwatch class to get the time.

private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
    {
        switch (e.Mode)
        {
            // Cuando regresa del sleep 
            case PowerModes.Resume:
                sleepStopwatch.Stop();
                break;
            // Cuando se va en sleep
            case PowerModes.Suspend:
                sleepStopwatch.Start(); 
                break;
        }
    }
Community
  • 1
  • 1