Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tray icon does not disappear on killing process

I have a window service for my application. When i stops that by killing process with task manager, the tray icon does not disappear. Is it a window bug or something else? Do we have a solution for that problem? Thanks in advance :).

like image 430
Lalit Avatar asked Feb 22 '10 15:02

Lalit


People also ask

How do I get rid of system tray arrow?

You can turn that off in settings. Settings - Personalisation - Taskbar - Select which icons appear on the taskbar - tick On. My Computers.

How do you force minimize to tray?

Press Alt + F1 and that window will minimize to the tray.

Why has my system tray disappeared?

One possible reason why the system tray icons are missing is that the system icons settings are currently off. For us to resolve this issue, we suggest that you change the settings of your computer.


2 Answers

You can let the icon disappear by calling the Dispose()-method of the specified NotifyIcon-object. In most cases these Container-object isn't part of the tree of components in your application so it will not disappear by killing the proces. When the user moves over the icon, the icon doesn't find it parent so it dissapears. But by calling the Dispose-method, it disapeared at least in my applications. So:

//creating a NotifyIcon
NotifyIcon notifyicon = new NotifyIcon();
notifyicon.Text = "Text"; 
notifyicon.Visible = true; 
notifyicon.Icon = new Icon(GetType(),"Icon.ico");
//let it disappear
notifyicon.Dispose();
like image 111
Willem Van Onsem Avatar answered Sep 21 '22 01:09

Willem Van Onsem


There is no solution to this problem. If you kill process with task manager, it does not receive termination notification, and hence can not remove its icon from the tray. Try avoiding killing process this way. You can use net start/stop to kill a service or services.msc GUI.

like image 39
alemjerus Avatar answered Sep 19 '22 01:09

alemjerus