comparison Implab/Safe.cs @ 238:bdfdba6b645b v2

fixed unpredictable Safe.Dispose behaviour
author cin
date Fri, 01 Dec 2017 01:28:56 +0300
parents 6fa235c5a760
children 5cb4826c2c2a
comparison
equal deleted inserted replaced
237:f2150c16b476 238:bdfdba6b645b
88 foreach (var d in objects) 88 foreach (var d in objects)
89 Dispose(d); 89 Dispose(d);
90 } 90 }
91 91
92 public static void Dispose(object obj) { 92 public static void Dispose(object obj) {
93 if (obj is IDisposable) { 93 if (obj is IDisposable)
94 Dispose((IDisposable)obj); 94 Dispose((IDisposable)obj);
95 } else if (obj is IEnumerable) { 95
96 DisposeCollection((IEnumerable)obj);
97 }
98 } 96 }
99 97
100 [DebuggerStepThrough] 98 [DebuggerStepThrough]
101 public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) { 99 public static void DispatchEvent<T>(this EventHandler<T> handler, object sender, T args) {
102 if (handler != null) 100 if (handler != null)