Context:
I'm developing a screensaver in C# with VS2010 .NET 4.0 on Windows 8.1. It's quite "busy", accessing a database on initial load and doing some image processing before displaying to multi-monitors.
Issue:
In most cases the process shuts down cleanly either a) on mouse/keyboard movement in /s mode or when desk.cpl is closed in /p mode. A problem arises thought when I run in /p mode (desk.cpl open) and then I instigate either "settings" (/c mode) or "Preview" (/s mode). Once these new processes are closed the /p mode returns as you would expect but when desk.cpl is closed the /p mode process continues to run. This is intermittent however - sometimes it closes, sometimes it doesn't.
In /p mode I explicitly don't close the form on mouse movement etc as this is not appropriate for the desk.cpl preview window. My assumption therefore is that desk.cpl would kill my process but this doesn't seem to be happening consistently.
Question:
How can I ensure that /p mode will close down consistently?