Avoiding disposing system-defined Pen and Brush instances

后端 未结 8 1997
离开以前
离开以前 2021-02-14 01:07

I understand it is best practise to call Dispose() on instances of Pen and Brush, except if they\'ve been set to the system-predefined values (eg. System.Drawing.Brushes, Syste

8条回答
  •  鱼传尺愫
    2021-02-14 01:58

    I could be wrong but I think you can assume that the lifetime (and the disposal) of the predefined brushes and pens is not your app's responsibility and will be handled by the system.

    In short: don't call Dispose on the predefined stuff. :)

提交回复
热议问题