From: thefiddler Date: Wed, 23 Jul 2014 07:21:20 +0000 (+0200) Subject: [OpenTK] Add allocated resource registry X-Git-Tag: 2.0-0~105^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77a44b2c8e1b8e8fb0795b35f24bb4846e211f98;p=platform%2Fcore%2Fcsapi%2Fopentk.git [OpenTK] Add allocated resource registry --- diff --git a/Source/OpenTK/Platform/PlatformFactoryBase.cs b/Source/OpenTK/Platform/PlatformFactoryBase.cs index 40dc0c1..95f1a8f 100644 --- a/Source/OpenTK/Platform/PlatformFactoryBase.cs +++ b/Source/OpenTK/Platform/PlatformFactoryBase.cs @@ -28,6 +28,7 @@ #endregion using System; +using System.Collections.Generic; using System.Diagnostics; using OpenTK.Graphics; using OpenTK.Input; @@ -42,12 +43,27 @@ namespace OpenTK.Platform /// abstract class PlatformFactoryBase : IPlatformFactory { + static readonly object sync = new object(); + readonly List Resources = new List(); + protected bool IsDisposed; public PlatformFactoryBase() { } + #region Protected Members + + protected void RegisterResource(IDisposable resource) + { + lock (sync) + { + Resources.Add(resource); + } + } + + #endregion + #region IPlatformFactory Members public abstract INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device); @@ -96,6 +112,13 @@ namespace OpenTK.Platform { if (manual) { + lock (sync) + { + foreach (var resource in Resources) + { + resource.Dispose(); + } + } } else {