Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是否需要在 OnPaint 事件中对通过 PaintEventArgs 获得的 Graphics 对象调用 Dispose()?
不,调用层(实际创建图形对象的层)负责这件事。还要考虑一下,当您在链上还有其他被调用者时,您将处置该对象,他们将无法使用它。
通常,您不应处置作为方法参数接收的 Graphic 对象。但是您应该处理自己创建的 Graphics 对象(例如使用该CreateGraphics方法)。
CreateGraphics