By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,081 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,081 IT Pros & Developers. It's quick & easy.

catch notifyicon kill attempt so dispose can run

P: n/a
I have a NotifyIcon application. (c# 2) I want to be able to catch a
kill/shutdown attempt so that I can call Dispose() to remove the icon. I
tried to create an event handler for ApplicationExit and put my icon
dispose call in there, but when process.kill() is called from an outside
app on the notifyicon app, the event doesn't get raised. the app closes
but the icon remains in the tray as dispose was never called.

any ideas?

another way of telling the notifyicon class that it needs to close?
Thanks.
Jul 19 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"deciacco" <a@awrote in message
news:GO******************************@giganews.com ...
>I have a NotifyIcon application. (c# 2) I want to be able to catch a
kill/shutdown attempt so that I can call Dispose() to remove the icon. I
tried to create an event handler for ApplicationExit and put my icon
dispose call in there, but when process.kill() is called from an outside
app on the notifyicon app, the event doesn't get raised. the app closes but
the icon remains in the tray as dispose was never called.

any ideas?

another way of telling the notifyicon class that it needs to close?
If TerminateProcess is called, which I guess is what Process.Kill probably
does, *no more code in the targetted process gets to run*. I just had to
work around this problem myself (process being killed, not using NotifyIcon)
and did so by having another process waiting on the process handle of the
first which is signalled when the process ends for any reason, triggering my
cleanup. Not sure how or even if you can do out-of-process cleanup with
shell notification icons though.
>

Thanks.

Jul 19 '07 #2

P: n/a

"deciacco" <a@awrote in message
news:GO******************************@giganews.com ...
>I have a NotifyIcon application. (c# 2) I want to be able to catch a
kill/shutdown attempt so that I can call Dispose() to remove the icon. I
tried to create an event handler for ApplicationExit and put my icon
dispose call in there, but when process.kill() is called from an outside
app on the notifyicon app, the event doesn't get raised. the app closes but
the icon remains in the tray as dispose was never called.

any ideas?

another way of telling the notifyicon class that it needs to close?
To follow up to my previous message -- the shell itself should wait on the
process handle for each process that has one or more tray icons, and remove
them if the process terminates. That it does not could be considered a bug.
Right now the icon is detected as an orphan and removed the next time the
user interacts with it in any way, like moving the mouse over it.
Jul 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.