The original problem:
- How to detect list of running apps?
I have a different take regarding the solution:
Some UWP apps has the main window title.
Checking main window title is not enough to say the app is running or not.
UWP apps in suspend state will still return the title (see the red rectangle)

So in order to detect the suspend state, we need to cover
- app has title but not running in the foreground
- app has title but not running in the background
{code}
static void byProcess()
{
Process[] processes = Process.GetProcesses();
List<string> suspendedAppsWhichHasTitle = new List<string>();
foreach (var proc in processes)
{
// if it has main window title
if (!string.IsNullOrEmpty(proc.MainWindowTitle))
{
// the app may be in suspend state
foreach (ProcessThread pT in proc.Threads)
{
ThreadState ts = pT.ThreadState;
if (ts == ThreadState.Running)
{
suspendedAppsWhichHasTitle.Add(proc.MainWindowTitle);
}
}
}
}
foreach(string app in suspendedAppsWhichHasTitle)
{
Console.WriteLine(app);
}
if (suspendedAppsWhichHasTitle.Count == 0)
{
Console.WriteLine("No visible app is running!");
}
Console.Read();
}
}