We frequently get the following warning:
AlwaysUpService has detected that the application has stopped.
However, in the logs of our application we can’t see anything pointing to the reason why the application stopped.
Why does AlwaysUp believe our application stopped? What is the criteria for the decision, that an application is considered as stopped?
Our application handles complex tasks. When it’s very busy, it might appear to hang. Could that be a reason for AlwaysUp to say it stopped?
I am pretty sure the process — normally visible in Task Manager — is not stopped, but I’m not 100% sure and I can not prove it. I am wondering if AlwaysUp might close the app by mistake.
Don’t worry! With a little detective work, we should be able to figure out what’s going on.
But first, let’s review how AlwaysUp monitors your application.
How AlwaysUp determines that your application stopped
After AlwaysUp launches your application as a service, it’s primary task is to watch your application and ensure that it’s always running. As such, AlwaysUp performs a battery of tests every few seconds to detect if your application is in trouble.
The most important check involves the state of your application’s process. But what is a process?
When Windows runs your application, it creates a process to track that specific instance of your running application. That process has an identifier (ID) and is visible on the “Details” tab in the Task Manager.
For example, process 9088 was created after we opened Notepad on our desktop:
And when we quit Notepad, process 9088 exited and disappeared from Task manager’s list.
Basically, a process tracks the lifetime of a running application. And everything running on your computer has at least one underlying process.
With that in mind, let’s return to AlwaysUp.
When AlwaysUp launches your application, Windows creates a process and returns it to AlwaysUp. Going forward, every two seconds, AlwaysUp asks Windows if the process is still alive or not. You can think of it like AlwaysUp opening the Task Manager and checking if the process is still on the list.
So when AlwaysUp says that your application has stopped, it’s because the application’s process is no longer active. In effect, the process has fallen off Task Manager’s list.
Investigate with Process Explorer
Have you ever used Microsoft’s free Process Explorer? It’s an amazing tool that can help you figure out what’s running on your machine — and why. Around here, we call it “Task Manager on steroids”. 🙂
Download Process Explorer and extract the zip file to your hard drive. We’ll need it for the next steps.
Dig into the tree of processes under AlwaysUp
Start Process Explorer. It will show all the applications running on your computer.
The leftmost Process column displays the hierarchical relationships between the processes. For example, if “Process A” started “Process B”, you will see “Process B” as a child of “Process A”. “Process B” will be displayed underneath “Process A”.
Now, let’s roll up our sleeves. If you haven’t already done so, please start your application in AlwaysUp. Afterwards, switch back to Process Explorer.
In the Process column, find AlwaysUpService.exe. That is the part of AlwaysUp that runs your application as a Windows Service. It will be a child of services.exe — the Windows Services Control Manager.
Your application should appear under AlwaysUpService.exe. For example, you can see that parent-child relationship when AlwaysUp is running Microsoft OneDrive as a service:
Does your application appear as a child of AlwaysUpService.exe?
Are other processes displayed in the tree as well?
Is this a “launcher” situation, where the application you provided to AlwaysUp starts another program and exits?
Look for anything unusual that may trick AlwaysUp into thinking that your application has stopped even though it’s still running.
Find out when your application started
If you think that your application hasn’t stopped, you should confirm that hypothesis with Process Explorer. Double-click your application’s entry to bring up the Properties window and look for the Started field.
For example, Process Explorer tells us that AlwaysUp last started OneDrive at 12:21:32 PM on March 27 2022:
If everything is working as expected, the start time should be close to the time reported in the AlwaysUp logs. Please be sure to let us know if the times are different because that would indicate a bug in AlwaysUp.
Best of luck with your application!