c# - Am I responsible for Disposing a BackgroundImage? -


I have a window form where I'm setting the background image in a custom bitmap image.

 Personal Image MakeCustomBackground () {bitmap result = new bitmap (100, 100); (Using the graphics canvas = graphics.frame image (result)) {// drag a custom image} return result; } Private Zero UpdateFromBackground () {this.BackgroundImage = MakeCustomBackground (); } 

My question is, the image is disposable and I am making it, what does it mean that I should settle it? Or when I pass the image through the background image, does it take ownership and it does not need to be settled?

assuming that UpdateFromBackground () is called more than once You should probably release the old image (before) setting a new setting. If you do not do this, then GC will eventually do this, but it is less efficient. The form only applies to the last bgIMage Will settle.

  Private Zero UpdateFromBackground () (If (this.BackgroundImage! = Null) {this.BackgroundImage.Dispose ();} This.BackgroundImage = MakeCustomBackground ();}  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -