6

I have a legacy Win32 application written in C++ that runs on the system continuously to monitor system health related parameters. Recently, I started facing an issue with the application getting suspended and becoming unresponsive thereafter on Windows 10 after every 2-3 days. After doing a bit of research, I came to know about a new feature introduced in the recent Windows 10 release that actively looks for processes that are not being actively used and suspends these processes to save system resources like CPU and RAM. While I came across several articles (one of the reference links is this) that state the Windows 10 has a wait time of around 5-10 seconds after which it moves the process to suspended state if the user is not actively using it. Now my application sends a UDP message to a remote server every 30 seconds indicating to the server that the application is running on the machine. Here are the questions that I have:

  1. Is there a way to prevent the application from being suspended or a way to increase this timeout to a relatively large value so that the application remains active?
  2. There are other non UI based application also running on my system which are relatively less active but they do not get suspended ever, Is this only applicable to UI based applications?
  3. While there were some references like this to add a special handling in your application to trap the suspending message from Windows and save the necessary state in your application but all these references are C# based. Can someone point me to a similar reference for C++?
  4. Is there some way I can track when and why Windows suspended the app in the form of some event logs or Windows logs?

Additional information: I tried to manually suspend/resume the application by using Resource Monitor and Process Explorer as the application does not get suspended instantly to understand the behavior but no luck. I have a feeling that his should be handled in the application itself and because it is not handled currently that the application becomes unresponsive.

Any help with be highly appreciated as I am stuck here for few days.

Thanks in advance!

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
iqstatic
  • 2,322
  • 3
  • 21
  • 39
  • Do you have a reference for the new Windows 10 feature you describe? The links you provided only apply to Store apps, not Win32 apps. In any case, can you rewrite the app to move its functionality to a background service? Sounds like something that it should have been doing from the beginning. I doubt the system would suspend services that are designed to run in the background. – Remy Lebeau Dec 16 '19 at 06:16
  • Yep, agree with @RemyLebeau. Windows thinks it's a standard foreground app and that's not what it is. – Carey Gregory Dec 16 '19 at 06:19
  • @RemyLebeau There is no direct reference to this feature in Windows 10 but many have faced this problem. There are many links like these: https://social.technet.microsoft.com/Forums/windows/en-US/a54dd52c-d78a-43c8-b547-6a227109c7e1/prevent-windows-10-from-suspending-processes?forum=win10itprohardware and https://answers.microsoft.com/en-us/windows/forum/all/windows-10-processes-becoming-suspended/bd577393-efb8-4a3b-9d44-35fe1612cb1b. – iqstatic Dec 16 '19 at 06:28
  • Exactly, I could not find a link specifically talking about Win32 applications but I feel it applies to all the processes, may be UI based applications as I mentioned in my question. I ran into some references mentioning background app behavior and how an app can be enabled to work in background but all of them apply to UWP apps I guess like here https://www.windowscentral.com/how-prevent-apps-running-background-windows-10. – iqstatic Dec 16 '19 at 06:33
  • @RemyLebeau, Can you give me some reference on how to make my application run as a background process? Please note that my application is a simple interactive UI based application. Will running it as a background hamper any of its functionality? – iqstatic Dec 16 '19 at 06:43
  • @iqstatic "*runs on the system continuously to monitor system health related parameters*" ... "*sends a UDP message to a remote server every 30 seconds*" - those are tasks that don't require a UI, and could (and should) be run in the background. I would suggest rewriting the app to separate the background logic to a [service](https://learn.microsoft.com/en-us/windows/win32/services/services), and have the UI simply communicate with the service to display status, set configurations, etc. – Remy Lebeau Dec 16 '19 at 16:11
  • Thanks @RemyLebeau. Thats helps clear some doubts. To give you more insights, the application monitors system health continuously and sends this data to the remote server periodically by itself and also when user selects an option on the UI on demand. This requires the process to be interactive. Rewriting the app to separate the core functionality to run as a background process would be a major architecture change but I guess that looks like the only option here. – iqstatic Dec 17 '19 at 09:16

0 Answers0