What event to use in WPF to update the application after the computer was resumed after hibernation or hibernation?

I have a WPF application that should update some data after restarting the computer from sleep mode or sleep mode. Details

If I continue to open the application and the sleeping computer (or sleep mode) after the computer resumes working, I want to see the application data update. No click or focus.

I tried to use the Application.Activated event, but it only works when I click or activate Applicaiton.

Which event should I use?

Thank you very much.

+4
source share
2 answers

You can look at the SystemEvent class. Probably PowerModeChanged will work.

+5
source

I think you should do this using the Windows Direct API, overriding WndProc and intercepting messages:

check this: Unable to catch shift / pause messages (winXP)

For example, when you resume hibernation, you will receive a WM_POWERBROADCAST message with the flag PBT_APMRESUMEAUTOMATIC .

0
source

Source: https://habr.com/ru/post/1380771/


All Articles