kas / percentage

See your battery percentage in the Windows 10 system tray
MIT License
365 stars 128 forks source link

More disposing #1

Closed jayotterbein closed 7 years ago

jayotterbein commented 7 years ago

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.

kas commented 7 years ago

Thank you for your fixes Jay!