Example #1
0
        private RenderTarget2D GetOrCreateInstance(bool forceCreate)
        {
            lock (Lock) {
                if (IsDisposed)
                {
                    throw new ObjectDisposedException("AutoRenderTarget");
                }

                if (IsInstanceValid)
                {
                    if (!forceCreate)
                    {
                        return(CurrentInstance);
                    }
                    else
                    {
                        lock (Coordinator.UseResourceLock)
                            CurrentInstance.Dispose();
                        CurrentInstance = null;
                    }
                }

                CurrentInstance      = CreateInstance();
                CurrentInstance.Name = Name;
                CurrentInstance.SetName(Name);

                return(CurrentInstance);
            }
        }