Hi, welcome to Microsoft Q&A.
Maybe you need to detect system wakeups to recreate downloads, or prevent the system from going to sleep.
Based on System Wake-up Events, when the system automatically wakes up, it broadcasts the PBT_APMRESUMEAUTOMATIC event to all applications.
A window receives PBT_APMRESUMEAUTOMATIC event through the WM_POWERBROADCAST message.
You can determine whether the system is awakened by detecting the WM_POWERBROADCAST message.
The code reference is as follows:
private const int POWERBROADCAST = 0x0218;
protected override void WndProc(ref Message m) {
switch (m.Msg) {
case POWERBROADCAST:
if (m.Msg==18)
//recreate the httpclient object or doing something else.
this.Invalidate();
break;
}
}
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.