Creates the System.Drawing.Graphics for the control.
The System.Drawing.Graphics for the control.
The System.Drawing.Graphics object that you retrieve through the Control.CreateGraphics method should not normally be retained after the current Windows message has been processed, because anything painted with that object will be erased with the next WM_PAINT message. Therefore you cannot cache the System.Drawing.Graphics object for reuse, except to use non-visual methods like System.Drawing.Graphics.MeasureString(string, System.Drawing.Font). Instead, you must call Control.CreateGraphics every time that you want to use the System.Drawing.Graphics object, and then call System.Drawing.Graphics.Dispose when you are finished using it. For more information about Windows messages, see Control.WndProc(Message@).
By design, Control.CreateGraphics sets ownership to the calling thread, and fails if it is called on other threads.
In addition to the Control.InvokeRequired property, there are four methods on a control that are thread safe: Control.Invoke(Delegate), Control.BeginInvoke(Delegate), Control.EndInvoke(IAsyncResult), and Control.CreateGraphics if the handle for the control has already been created. Calling Control.CreateGraphics before the control's handle has been created on a background thread can cause illegal cross thread calls. For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread.