There were two items not being disposed of that could be in the timer_tick method: when setting an Icon property it's actually copied rather than set directly (not intuitive at all). The other is that the IntPtr returned by GetHIcon has to manually freed by DestroyIcon.
I migrated the part about getting the size to its own method so that using statements could be used more easily, which ensures items get disposed of even if there's an error rather than a manual Dispose() call.
There were two items not being disposed of that could be in the
timer_tick
method: when setting anIcon
property it's actually copied rather than set directly (not intuitive at all). The other is that theIntPtr
returned byGetHIcon
has to manually freed byDestroyIcon
.I migrated the part about getting the size to its own method so that
using
statements could be used more easily, which ensures items get disposed of even if there's an error rather than a manualDispose()
call.