using (LinearGradientBrush brush1 = new LinearGradientBrush(GradientRectangle, StartColor, EndColor, 90f)) { e.Graphics.FillRectangle(brush1, GradientRectangle); }The .NET Brush is a wrapper around a GDI/GDI+ unmanaged resource and really should be treated as something in limited supply. By applying the creation of the brush inside the using statement you will get the benefit of having code generated by the compiler to automatically call Dispose on classes that implement the IDisposable interface to release any unmanaged resources inside a try...catch block.