According to MSDN documentation
ResumeAutomatic : The computer has woken up automatically to handle an event.
Note : If the system detects any user activity after broadcasting ResumeAutomatic, it will broadcast a ResumeSuspend event to let applications know they can resume full interaction with the user.
ResumeSuspend : The system has resumed operation after being suspended.
Does this mean 'ResumeAutomatic' is called when the computer wakes up from sleep and 'ResumeSuspend' is called when the user logs in after entering credentials?
I am using tcp socket to communicate with a server. So in order to reconnect to the service when the system is back from sleeping state, I have the following code
protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus)
{
Logger.Log("Power status is : " + powerStatus);
if (powerStatus == PowerBroadcastStatus.ResumeAutomatic)
{
ConnectionWatchdog.ReConnect();
}
return base.OnPowerEvent(powerStatus);
}
But I observe that the enum values are random. Below are 3 different traces at 3 different wake up times.
20150525#094449 :: Power status is : Suspend
20150525#094716 :: Power status is : ResumeSuspend
20150525#103431 :: Power status is : Suspend
20150525#103525 :: Power status is : ResumeSuspend
20150525#103525 :: Power status is : ResumeAutomatic
20150525#103558 :: Power status is : Suspend
20150525#103835 :: Power status is : ResumeAutomatic
(This is not how it all works in practice - see below.)
This message is always sent when the computer has resumed after sleep.
The computer has resumed after sleep, and Windows believes a user is present - i.e. that there is a human sitting in front of the machine. This message is sent when either a) the wake was caused by human interaction (someone pressing the power button, pressing a key, moving the mouse, etc); or b) the first time there is human interaction after the machine wakes automatically due to a wake timer.
To directly answer your question, ResumeSuspend is sent the first time a user interacts with the computer. This could be entering a password to unlock it, but it doesn't have to be. If the user just wiggles the mouse, ResumeSuspend will still be sent.
I've had the misfortune of having to go deep inside the rabbit hole of Windows' support for power management, profiles, etc. The Vista-era stuff is frustrating, because it's based on quality and thoughtful design, but both the implementation and documentation is not quite there, and has never been fixed. There are numerous other niggling problems I've not gone into here. It's all a bit of a shame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With