public static GraphicsDeviceService AddRef(IntPtr windowHandle, int width, int height) { if(Interlocked.Increment(ref referenceCount) == 1) { instance = new GraphicsDeviceService(windowHandle, width, height); } return instance; }
protected override void OnCreateControl() { if (!DesignMode) { graphicsDeviceService = GraphicsDeviceService.AddRef(this.Handle, this.Width, this.Height); services.AddService(typeof(IGraphicsDeviceService), graphicsDeviceService); Initialize(); } base.OnCreateControl(); }
protected override void Dispose(bool disposing) { if (graphicsDeviceService != null) { graphicsDeviceService.Release(disposing); graphicsDeviceService = null; } if (disposing) contentMgr.Unload(); base.Dispose(disposing); }