comparison Implab/Components/Disposable.cs @ 213:9ee78a345738 v2

Minor code changes
author cin
date Tue, 11 Apr 2017 01:35:18 +0300
parents 7d07503621fe
children 9f63dade3a40
comparison
equal deleted inserted replaced
212:a01d9df88d74 213:9ee78a345738
6 namespace Implab.Components { 6 namespace Implab.Components {
7 /// <summary> 7 /// <summary>
8 /// Base class the objects which support disposing. 8 /// Base class the objects which support disposing.
9 /// </summary> 9 /// </summary>
10 public class Disposable : IDisposable { 10 public class Disposable : IDisposable {
11 11
12 int m_disposed; 12 int m_disposed;
13 13
14 public event EventHandler Disposed; 14 public event EventHandler Disposed;
15 15
16 public bool IsDisposed { 16 public bool IsDisposed {
73 /// <remarks> 73 /// <remarks>
74 /// Данный метод вызывается гарантированно один раз даже при одновременном вызове <see cref="Dispose()"/> 74 /// Данный метод вызывается гарантированно один раз даже при одновременном вызове <see cref="Dispose()"/>
75 /// из нескольких потоков. 75 /// из нескольких потоков.
76 /// </remarks> 76 /// </remarks>
77 protected virtual void Dispose(bool disposing) { 77 protected virtual void Dispose(bool disposing) {
78 if (disposing) { 78 if (disposing)
79 EventHandler temp = Disposed; 79 Disposed.DispatchEvent(this, EventArgs.Empty);
80 if (temp != null) 80
81 temp(this, EventArgs.Empty);
82 }
83 } 81 }
84 82
85 [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "Dipose(bool) and GC.SuppessFinalize are called")] 83 [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly", Justification = "Dipose(bool) and GC.SuppessFinalize are called")]
86 public void Dispose() { 84 public void Dispose() {
87 if (Interlocked.Increment(ref m_disposed) == 1) { 85 if (Interlocked.Increment(ref m_disposed) == 1) {