//on shutdown this method is called. it stoppeds the thread and releases the resources and graphics card private void ShutDown() { _renderer.RequestShutdown(); if (!CustomVertex.VertexPositionColor.VertexDecl.Disposed) { CustomVertex.VertexPositionColor.VertexDecl.Dispose(); } if (!CustomVertex.VertexPositionNormalColor.VertexDecl.Disposed) { CustomVertex.VertexPositionNormalColor.VertexDecl.Dispose(); } while (!DeviceManager.LocalDevice.Disposed && !_renderThread.IsAlive) { DeviceManager.LocalDevice.EvictManagedResources(); DeviceManager.LocalDevice.Direct3D.Dispose(); DeviceManager.LocalDevice.Dispose(); } }