0

my problem occures on Windows 7.

Background:

I have two applications:

a) MainApp - software which should always run in foreground, maximized (with no taskbar)

b) Watchdog - software which monitors MainApp if it runs properly and starts new MainApp instance if one is closed.

Problem:

Everything works well. But I noticed that sometimes on Windows 7 MainApp starts minimized - it shows icon on taskbar, WindowState is "Maximized" (checked in logs), but Form is not visible until I restore it from taskbar. Problem not occuring on Windows 10 (other not checked).

Reproduce steps I managed to reproduce this problem by:

a) Run Watchdog + MainApp

b) Click Win+D (minimize all windows)

c) Close MainApp (with mouse from taskbar)

d) Watchdog is restarting MainApp minimized <= PROBLEM!!

Show me the code

Watchdog starts MainApp by simply executing:

var info = new ProcessStartInfo();
info.FileName = clientExePath;
info.UseShellExecute = false;
Process.Start(info);

Expected behaviour

MainApp starts in front of all other windows, visible.

Does anyone know how to handle this problem?

EDIT 1

I found out that calling extern method from Shell32.dll

void ToggleDesktop();

restores all windows. But I don't know how to check whether all windows minimized (to fire this method). Additionaly it restores all opened windows, so it is not sure that MainApp form will be the most-first one.

Pawel
  • 280
  • 3
  • 10
  • Sounds like you are trying to reinvent not one, but two wheels. The watchdog can be replaced with the Restart Manager. And the overall scenario sounds like you should be using Kiosk Mode – IInspectable Dec 03 '17 at 21:37
  • @IInspectable - restarting application is one of many responsibilities of Watchdog. But anyway, I will look for Kiosk Mode - if I understand it correctly it is part of Windows? I don't know if it will satisfy my client, so any other help would be appreciated. – Pawel Dec 07 '17 at 15:18

0 Answers0