/// <summary> /// Rather than disposing the wrapper or the <see cref="Value"/>, returns the wrapper to the pool specified in the wrapper's constructor. /// </summary> public void Dispose() { try { _Pool.Add(this); } catch (ObjectDisposedException) { (this.Value as IDisposable)?.Dispose(); } }
protected override void WriteFilteredEvent(LogEvent logEvent) { if (_Events.Count >= _MaximumCapacity) { var item = _Events[0]; _Events.RemoveAt(0); _Pool.Add(item); } var newEntry = _Pool.Take(); logEvent.Clone(newEntry); _Events.Add(newEntry); }
/// <summary> /// Clones the supplied <see cref="LogEvent"/> instance and adds the clone to the list. /// </summary> /// <param name="logEvent">A <see cref="LogEvent"/> instance to clone and add to the queue.</param> protected override void WriteEventInternal(LogEvent logEvent) { if (logEvent == null) { return; } if (_Events.Count >= _MaximumCapacity) { var item = _Events[0]; _Events.RemoveAt(0); _Pool.Add(item); } var newEntry = _Pool.Take(); logEvent.Clone(newEntry); _Events.Add(newEntry); OnEventWritten(logEvent); }
public virtual void Simulate(GameTime gameTime) { if (EnableGenerate) { Generate(gameTime); } for (int i = 0; i < particles.Count; i++) { if (particles[i].Color.W <= 0) { particlePool2D.Add(particles[i]); particles.RemoveAt(i); i--; continue; } if (particles[i].Position.Y + globalTransform.Position.Y > 400) { particles[i].Acceleration = new Vector2(rnd.RandomVector2(20, 0).X, -20); } particles[i].Update(gameTime); } }