protected override void Dispose(bool disposing) { if (this.service != null) { this.service.Release(disposing); this.service = null; if (this.gameLoopThread != null && this.gameLoopThread.IsAlive) { this.gameLoopThread.Abort(); } } base.Dispose(disposing); }
protected override void OnCreateControl() { if (!this.DesignMode) { this.service = GraphicsDeviceService.AddReference( Handle, ClientSize.Width, ClientSize.Height); this.service.DeviceReset += new EventHandler<EventArgs>(onDeviceReset); this.services.AddService<IGraphicsDeviceService>(service); if (this.GameLoopEnabled) { this.gameLoopThread = new Thread(this.gameLoop); this.gameLoopThread.IsBackground = true; this.gameLoopThread.Priority = ThreadPriority.Normal; this.gameLoopThread.Start(); } else { this.LoadContent(); } } base.OnCreateControl(); }
public static GraphicsDeviceService AddReference(IntPtr windowHandle, int width, int height) { if (Interlocked.Increment(ref referenceCount) == 1) { instance = new GraphicsDeviceService(windowHandle, width, height); } return instance; }