I made a screensaver in .Net 4.0. It basically just moves the bits in an image around and displays it using .Invalidate on a timer and overriding the onPaint event.
So far, it works great – however – I noticed one problem with it.
It’s stopping the monitor from suspending after the suspend timeout. Since I installed it, my monitor stays on 24/7 now.
The thing is, I didn’t do anything to specifically stop power savings features – and I’ve made sure that my computer’s power savings settings are set (they are). So then I chose another screensaver just to be sure the settings were still working. The monitor suspended after the timeout.
What do I need to do then to play nice with power management? I searched for this answer on Google and everything I found is how to block power management and I didn’t explicitly block it! I just want the suspend to be allowed when it’s time.
I was able to get my program to “play nice”. I don’t know why this works and the original code didn’t, but this not only works – it actually makes the program more “power savings” friendly because it reduces CPU cycles by not doing calculations after the screen suspends. In short, I preview the WndProc messages and look for the monitor is being suspended message and once it’s received, I stop redrawing until it resumes (it’s possible to resume and have the screensaver still active).
Code changes:
Making this change stops all the redrawing when a suspend is called (and stops the GDI+ calculations) and after making it, the screensaver “behaves” with power management settings.