I have simple application, with hidden form and not displaying on taskbar (settings of form), with one purpose - show tray icon, when service is running.
Service is implemented by me as well, and uses duplex callback to send message to this application. When it is about to stop, it sends message to applicaion, so it hides tray icon. The thing is, that i need to show icon, when service is up again. For now I'm doing this with WaitForService
with no timeout.
if (sc.Status != ServiceControllerStatus.Running)
sc.WaitForStatus(ServiceControllerStatus.Running);
_notifyIcon.Visible = true;
This works ok - code suspends its execution, until service is up again.
But there is one problem - if application waits over some time, it is marked as "Not responding", it appears in taskbar, and some sort of small window appears. So, is there any alternative to avoid that? Either some workaround for WaitForStatus
, or different method for monitoring service status.