Re: GDI Objects not releaseing
- From: "Smokey Grindel" <nospam@xxxxxxxxxx>
- Date: Wed, 17 Oct 2007 11:05:32 -0400
I seem to get a Cannot access a disposed object error if I dispose the icon
directly off the notifyicon control... any ways around this?
"Phill W." <p-.-a-.-w-a-r-d-@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:ff552a$pl6$1@xxxxxxxxxxxxxxxxxxxx
Smokey Grindel wrote:
I have an application that has a system tray icon, which updates every 10
seconds to a custom made image... and every time it updates my GDI object
count increments, this shouldn't happen, any ideas on what to look for?
If you create it, and can Dispose of it when you're done with it, then do
so.
ntfIcon.Icon = New Icon(Icon.FromHandle(bmp.GetHicon), New Size(16, 16))
GDI objects tend to wrap up Unmanaged resources and, if you don't
explicitly Dispose of them, they'll hang around, holding onto those
precious resources, until Garbage Collection [finally] gets around to
clearing them up; which /might/ not be for hours!
Try something like this:
Dim icon as New Icon( ...
If Not ( ntfIcon Is Nothing ) Then
ntfIcon.Dispose()
ntfIcon = icon
End If
HTH,
Phill W.
.
- References:
- GDI Objects not releaseing
- From: Smokey Grindel
- Re: GDI Objects not releaseing
- From: Phill W.
- GDI Objects not releaseing
- Prev by Date: Re: Adding a record to an existing Dataset
- Next by Date: Re: GDI Objects not releaseing
- Previous by thread: Re: GDI Objects not releaseing
- Next by thread: Re: GDI Objects not releaseing
- Index(es):
Relevant Pages
|