/// <summary>
		/// Gets a reference to the singleton instance.
		/// </summary>
		public static GraphicsDeviceService AddRef(IntPtr windowHandle, int width, int height, GraphicsProfile profile) {
			// Increment the "how many controls sharing the device" reference count.
			if (Interlocked.Increment(ref mReferenceCount) == 1) {
				// If this is the first control to start using the
				// device, we must create the singleton instance.
				mSingletonInstance = new GraphicsDeviceService(windowHandle, width, height, profile);
			}

			return mSingletonInstance;
		}
		/// <summary>
		/// Initializes the control.
		/// </summary>
		protected override void OnCreateControl() {
			// Don't initialize the graphics device if we are running in the designer.
			if (!DesignMode) {
				mGraphicsDeviceService = GraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height, TargetGraphicsProfile);

				// Register the service, so components like ContentManager can find it.
				Services.AddService<IGraphicsDeviceService>(mGraphicsDeviceService);

				// Give derived classes a chance to initialize themselves.
				Initialize();
			}

			base.OnCreateControl();
		}
        /// <summary>
        /// Initializes the control.
        /// </summary>
        protected override void OnCreateControl()
        {
            // Don't initialize the graphics device if we are running in the designer.
            if (!DesignMode)
            {
                mGraphicsDeviceService = GraphicsDeviceService.AddRef(Handle, ClientSize.Width, ClientSize.Height, TargetGraphicsProfile);

                // Register the service, so components like ContentManager can find it.
                Services.AddService <IGraphicsDeviceService>(mGraphicsDeviceService);

                // Give derived classes a chance to initialize themselves.
                Initialize();
            }

            base.OnCreateControl();
        }
		/// <summary>
		/// Disposes the control.
		/// </summary>
		protected override void Dispose(bool disposing) {
			if (mGraphicsDeviceService != null) {
				mGraphicsDeviceService.Release(disposing);
				mGraphicsDeviceService = null;
			}

			base.Dispose(disposing);
		}