public void Push(object message) { if (ShouldDispose()) { _disposeCount++; Disposed.Raise(this); } }
public void Dispose() { var args = new EventArgs <T>(this.InternalObject); disposed(this, args); if (Disposed != null) { Disposed.Raise(this, args.Value); } }
public virtual void Dispose() { if (isDisposed) { var message = string.Format("Object already disposed: {0}", this); throw new ObjectDisposedException(message); } isDisposed = true; Disposed.Raise(this); }
private void OnSubscriptionDisposed(object sender, EventArgs e) { try { _rwLock.EnterWriteLock(); _subscriptions.Remove(sender as IDisposableSubscription); Disposed.Raise(sender); } finally { _rwLock.ExitWriteLock(); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (IsDisposed) { return; } GC.SuppressFinalize(this); _isDisposed = true; Dispose(true); if (Disposed != null) { Disposed.Raise(this, EventArgs.Empty); } }
/// <summary> /// Immediately terminates the <see cref="IParticleEffect"/> and all <see cref="IParticleEffect"/>s in it. /// </summary> public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; // Dispose all emitters foreach (var e in _emitters) { e.Dispose(); } if (Disposed != null) { Disposed.Raise(this, EventArgs.Empty); } }
private void Dispose(bool disposing) { if (m_isDisposed) { return; } Disposing.Raise(this, EventArgs.Empty); if (disposing) { DisposeManagedResources(); } DisposeUnmanagedResources(); Disposed.Raise(this, EventArgs.Empty); Disposing.Dispose(); Disposed.Dispose(); m_isDisposed = true; }
/// <summary> /// Disposes of the <see cref="Entity"/>. /// </summary> public void Dispose() { // Check if the Entity has already been disposed if (IsDisposed) { return; } GC.SuppressFinalize(this); _isDisposed = true; // Notify listeners that the Entity is being disposed if (Disposed != null) { Disposed.Raise(this, EventArgs.Empty); } // Handle the disposing HandleDispose(true); }
/// <summary> /// Immediately terminates the <see cref="IParticleEmitter"/> and all <see cref="Particle"/>s in it. /// </summary> public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; // Dispose the particles so they can be used again foreach (var particle in _particles) { if (particle != null && !particle.IsDisposed) { particle.Dispose(); } } if (Disposed != null) { Disposed.Raise(this, EventArgs.Empty); } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public virtual void Dispose() { if (IsDisposed) { return; } IsDisposed = true; try { // Clear the atlas (if one exists) if (_atlas != null && !_atlas.IsDisposed) { try { _atlas.Dispose(); } catch (Exception ex) { const string errmsg = "Failed to dispose `{0}`. Exception: {1}"; if (log.IsWarnEnabled) { log.WarnFormat(errmsg, _atlas, ex); } Debug.Fail(string.Format(errmsg, _atlas, ex)); } } if (_mapAtlases != null) { // Clear the map atlas images foreach (var atlas in _mapAtlases) { try { if (atlas != null && !atlas.IsDisposed) { atlas.Dispose(); } } catch (Exception ex) { const string errmsg = "Failed to dispose `{0}`. Exception: {1}"; if (log.IsWarnEnabled) { log.WarnFormat(errmsg, atlas, ex); } Debug.Fail(string.Format(errmsg, atlas, ex)); } } // Clear the atlas list _mapAtlases.Clear(); } } catch (Exception ex) { const string errmsg = "Failed to dispose `{0}`. Exception: {1}"; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, this, ex); } Debug.Fail(string.Format(errmsg, this, ex)); } if (Disposed != null) { Disposed.Raise(this, EventArgs.Empty); } }
public void Dispose() { IsDisposed = true; Disposed.Raise(this); }
private void raiseDispose() { IsDisposed = true; action = null; Disposed.Raise(this); }
public void Dispose() { Disposed.Raise(this, this.Handle); }