Changed implementation of IDisposable to proper way.

This commit is contained in:
Harrison Deng 2018-12-29 00:23:29 -06:00
parent e137796b46
commit 3bbbd672be

View File

@ -1,10 +1,12 @@
using Microsoft.Xna.Framework; using Microsoft.Win32.SafeHandles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.Camera; using RecrownedAthenaeum.Camera;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,6 +16,8 @@ namespace RecrownedAthenaeum.ScreenSystem
public class ScreenManager : IDisposable public class ScreenManager : IDisposable
{ {
bool disposed = false;
public event FirstScreenChange RequireNextScreenEvent; public event FirstScreenChange RequireNextScreenEvent;
private GraphicsDeviceManager graphics; private GraphicsDeviceManager graphics;
private Screen previousScreen; private Screen previousScreen;
@ -131,7 +135,18 @@ namespace RecrownedAthenaeum.ScreenSystem
public void Dispose() public void Dispose()
{ {
previousScreenRenderTarget?.Dispose(); Dispose(true);
GC.SuppressFinalize(this);
}
public virtual void Dispose(bool disposing)
{
if (disposed) return;
if (disposing)
{
previousScreenRenderTarget?.Dispose();
}
disposing = true;
} }
} }
} }