Re: catch notifyicon kill attempt so dispose can run




"deciacco" <a@a> wrote in message
news:GOudnWSnT5SgfgPbnZ2dnUVZ_hqdnZ2d@xxxxxxxxxxxxxxx
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.


.



Relevant Pages

  • catch notifyicon kill attempt so dispose can run
    ... I tried to create an event handler for ApplicationExit and put my icon dispose call in there, but when process.killis called from an outside app on the notifyicon app, the event doesn't get raised. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: GCI object leak - what is the solution to this line of code?
    ... Dispose will only call DestroyIcon when it owns the handle and it doesn't ... Can you confirm which version of .Net Framework you are using? ... "Bug Details: System.Drawing.Icon.Disposedoes nothing" ... GDI Handles Leak When You Assign an Icon to a Windows Form" ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: [Bug Suspicion] So, <any_gdi_object>.Dispose() does ... what exactly?
    ... In the egghead code I did not see a Dispose of the Icon created each tick. ... Looking at the UpdateIcon method in NotifyIcon I see potential for other ... >> The GDI objects counter in the task manager increases by 3 per every ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: GDI Objects not releaseing
    ... I seem to get a Cannot access a disposed object error if I dispose the icon ... GDI objects tend to wrap up Unmanaged resources and, ... Dim icon as New Icon(... ... If Not (ntfIcon Is Nothing) Then ...
    (microsoft.public.dotnet.languages.vb)
  • Re: catch notifyicon kill attempt so dispose can run
    ... kill/shutdown attempt so that I can call Dispose() to remove the icon. ... tried to create an event handler for ApplicationExit and put my icon ... app on the notifyicon app, ...
    (microsoft.public.dotnet.languages.csharp)