/// <summary> Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="explicitDisposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param> protected virtual void Dispose(bool explicitDisposing) { if (explicitDisposing) { if (Interlocked.Exchange(ref _isDisposed, 1) > 0) { return; } Interlocked.Increment(ref StatisticsːMethodInvocationːDisposeːCount); foreach (var child in _children) { child.Dispose(); } foreach (var disposable in _disposableObjects) { disposable.Dispose(); } _children.Clear(); _disposableObjects.Clear(); if (LazyWeakEventStore.IsValueCreated) { LazyWeakEventStore.Value.Dispose(); } EventUtil.RaiseDisposedEvent(Disposed, this); } }
/// <summary> Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="explicitDisposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param> protected virtual void Dispose(bool explicitDisposing) { if (explicitDisposing) { if (Interlocked.Exchange(ref _isDisposed, 1) > 0) { return; } Interlocked.Increment(ref StatisticsːMethodInvocationːDisposeːExplicitːCount); EventUtil.RaiseDisposedEvent(Disposed, this); if (LazyWeakEventStore.IsValueCreated) { LazyWeakEventStore.Value.Dispose(); } } }