public void Release(bool disposing)
{
// Decrement the "how many controls sharing the device" reference count.
if (Interlocked.Decrement(ref referenceCount) == 0)
{
// If this is the last control to finish using the
// device, we should dispose the singleton instance.
if (disposing)
{
if (this.DeviceDisposing != null)
this.DeviceDisposing(this, EventArgs.Empty);
this.graphicsDevice.Dispose();
}
this.graphicsDevice = null;
}
}