private static void Run(object context) { bool looping = true; Main.instance.add_Exiting((EventHandler <EventArgs>)((obj, args) => { looping = false; if (!Monitor.TryEnter(TextureManager._loadThreadLock)) { return; } Monitor.Pulse(TextureManager._loadThreadLock); Monitor.Exit(TextureManager._loadThreadLock); })); Monitor.Enter(TextureManager._loadThreadLock); while (looping) { if (TextureManager._loadQueue.Count != 0) { TextureManager.LoadPair result; if (TextureManager._loadQueue.TryDequeue(out result)) { result.TextureRef.Value = TextureManager.Load(result.Path); } } else { Monitor.Wait(TextureManager._loadThreadLock); } } Monitor.Exit(TextureManager._loadThreadLock); }
public static Ref <Texture2D> AsyncLoad(string name) { return(new Ref <Texture2D>(TextureManager.Load(name))); }