diff Implab/Safe.cs @ 128:6241bff0cd64 v2

Added Signal class a lightweight alternative to ManualResetEvent
author cin
date Thu, 29 Jan 2015 05:09:31 +0300
parents f7b2b8bfbb8c
children b5c2d609d71b
line wrap: on
line diff
--- a/Implab/Safe.cs	Tue Jan 27 18:18:29 2015 +0300
+++ b/Implab/Safe.cs	Thu Jan 29 05:09:31 2015 +0300
@@ -36,13 +36,26 @@
                 throw new ArgumentOutOfRangeException(paramName);
         }
 
-        public static void Dispose(params IDisposable[] objects)
-        {
-            foreach(var d in objects)
+        public static void Dispose(params IDisposable[] objects) {
+            foreach (var d in objects)
                 if (d != null)
                     d.Dispose();
         }
 
+        public static void Dispose(params object[] objects) {
+            foreach (var obj in objects) {
+                var d = obj as IDisposable;
+                if (d != null)
+                    d.Dispose();
+            }
+        }
+
+        public static void Dispose(object obj) {
+            var d = obj as IDisposable;
+            if (d != null)
+                d.Dispose();
+        }
+
         [DebuggerStepThrough]
         public static IPromise<T> InvokePromise<T>(Func<T> action) {
             ArgumentNotNull(action, "action");