Question closing NotifyIcon cleanly

gchq

Well-known member
Joined
Dec 14, 2007
Messages
168
Programming Experience
10+
I noticed that when the app closed the icon remained on the taskbar until the mouse was hovered over it, so added this:-

VB.NET:
                    If Not AlarmClockNotify Is Nothing Then
                        AlarmClockNotify.Dispose()
                    End If

.. and that did the job.

Then I noticed that if the balloon was showing at the time the app was closed, the icon went - but the balloon stayed, so added this:-


VB.NET:
 If Not AlarmClockNotify Is Nothing Then
                    AlarmClockNotify.Visible = False
                    AlarmClockNotify.Visible = True
                    AlarmClockNotify.Dispose()
                End If


and everything worked fine until the app was closed WITHOUT the icon showing (only dislays if an alarm is pending in the next x days) - then it throws and 'object reference not set to an instance of an object' - odd becuase it passed straight through the 'not is nothing' If statement.

Any ideas?

Thanks
 
Paszt - thanks for your reply

1. The form is loaded dynamically from a much larger app

2. IsDisposed (according to VS2005) is not a property of NotifyIcon


I think, however, I may have gotten round the problem - the function that decides if the NotifyIcon should be displayed was calling .Disposed if not needed. I have now changed that to .Visible=False and so far it seems to be holding up...
 
Back
Top