467,179 Members | 1,419 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

How to refresh System Tray in C#

Dear everyone,

In my application, I kill process by:

private bool KillProcess(String processName)
{
bool result = false;
Process[] process =
Process.GetProcessesByName(processName);
for (int i = 0; i < process.Length; i++)
{
Process.GetProcessById(process[i].Id).Kill();
result = true;
}
return result;
}
this process will be killed, but an icon of this process still at
system tray until it is repained. Please show me the solution to
refresh System Tray.

Many thanks,
bipi

Sep 6 '06 #1
  • viewed: 8962
Share:
5 Replies
>this process will be killed, but an icon of this process still at
system tray until it is repained. Please show me the solution to
refresh System Tray.
Can't you close the application in a more graceful way that lets it
clean up properly?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 6 '06 #2

Mattias Sjögren wrote:
Can't you close the application in a more graceful way that lets it
clean up properly?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
This problem's the same as you are running MS OutLook and the icon of
Outlook will show in system tray but when you use "Windows Task
Manager" to "end process" outlook, the outlook icon still at System
Tray. Please help me !

Sep 6 '06 #3
What if you add an icon to the tray and then remove it correctly?
I think this will cause the tray to refresh...

bipi a scris:
Mattias Sjögren wrote:
Can't you close the application in a more graceful way that lets it
clean up properly?
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

This problem's the same as you are running MS OutLook and the icon of
Outlook will show in system tray but when you use "Windows Task
Manager" to "end process" outlook, the outlook icon still at System
Tray. Please help me !
Sep 6 '06 #4

sb*****@gmail.com wrote:
What if you add an icon to the tray and then remove it correctly?
I think this will cause the tray to refresh...

bipi a scris:
Mattias Sjögren wrote:
Hey you, I try to do it which solution you give me. I put NotifyIcon in
my application and after kill process A(A is process name), I show my
icon and hide it later. The icon of process A is still at system tray.
But when I move mouse over this icon, it disappears immediately.

Do you have any ideas ! please show me !

Many thanks,

Sep 7 '06 #5
>This problem's the same as you are running MS OutLook and the icon of
>Outlook will show in system tray but when you use "Windows Task
Manager" to "end process" outlook, the outlook icon still at System
Tray.
That's why I'm questioning your need to kill the process. There are
usually better ways to close an application.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Sep 7 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by elziko | last post: by
3 posts views Thread by Nicolas Poirier | last post: by
3 posts views Thread by joe | last post: by
10 posts views Thread by Crouchie1998 | last post: by
1 post views Thread by =?Utf-8?B?RW5naW5lZXJpaw==?= | last post: by
3 posts views Thread by Usman Jamil | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.