Dispose of Notifier Icon

G

Guest

Thank you in advance for any and all assistance.

I have an application that places a notifier icon in the start tray. When
the application closes, the icon appears to stay, till I place my mouse over
it and then it will disappear. Can someone point in the direction of code to
dispose of the notifier icon when the application closes?

Michael
 
G

Guest

you can either, in your formClosing even, say

Me.NotifyIcon1.Visible = False

in VB2005 i believe there is an application exit event...., so you could
also say that in there
 
C

Cor Ligthert [MVP]

iwdu15

Keep it by your first answer, don't tell what you believe is. :)

There are almost 10 methods to start a VB application.

If you use the standard method than the application exit is standard done in
your main form as that closes

If you write your own Sub Main to let the application run, than you have to
end that with application.exit.
(this is the method as by instance Herfried always shows)

Just what I thought reading your message.

Cor
 
J

Jay B. Harlow [MVP - Outlook]

Michael,
In addition to the other comments.

Be certain to call Dispose on the NotifyIcon when you app exits, this
ensures that any unmanaged resources its holding are cleaned up. I would not
use the visible = false method as that is "hiding the icon" rather then
"clean up the resources"...

Do you have an forms application that happens to have a notify icon, or do
you happen to have a notify icon that happens to have a form?

When I have a notify icon that happens to have a form I normally do
something like:
http://groups.google.com/group/micr...2baa27752c8?lnk=st&q=&rnum=1#0f48f2baa27752c8

http://groups.google.com/group/micr...02af50ca7de?lnk=st&q=&rnum=2#4998f02af50ca7de

http://groups.google.com/group/micr...2a27479a427?lnk=st&q=&rnum=3#ddb0f2a27479a427

If I had a forms application that happens to have a notify icon, I would be
certain to call dispose of the icon when the form closed (or the application
exited).

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


in message | Thank you in advance for any and all assistance.
|
| I have an application that places a notifier icon in the start tray. When
| the application closes, the icon appears to stay, till I place my mouse
over
| it and then it will disappear. Can someone point in the direction of code
to
| dispose of the notifier icon when the application closes?
|
| Michael
 
G

Guest

just a question for you, i havent done much reading on the memory management
of VB, but i was under the impression that VB was managed by the GC, so when
the application exits, there isnt anything associated with the NotifyIcon
object so the GC would collect it and release the resources....am i following
this wrong?
 
J

Jay B. Harlow [MVP - Outlook]

iwdu15,
Yes managed resources are "managed" by the GC.

However NotifyIcon represents an unmanaged resource. The GC doesn't really
manage unmanaged resources.

Also remember that the GC, more appropriately any Finalizers may not execute
when the app exits. Ergo its best to call NotifyIcon.Dispose when you are
exiting.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


"iwdu15" <jmmgoalsteratyahoodotcom> wrote in message
| just a question for you, i havent done much reading on the memory
management
| of VB, but i was under the impression that VB was managed by the GC, so
when
| the application exits, there isnt anything associated with the NotifyIcon
| object so the GC would collect it and release the resources....am i
following
| this wrong?
| --
| -iwdu15
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top