comparison 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
comparison
equal deleted inserted replaced
127:d86da8d2d4c3 128:6241bff0cd64
34 public static void ArgumentInRange(int value, int min, int max, string paramName) { 34 public static void ArgumentInRange(int value, int min, int max, string paramName) {
35 if (value < min || value > max) 35 if (value < min || value > max)
36 throw new ArgumentOutOfRangeException(paramName); 36 throw new ArgumentOutOfRangeException(paramName);
37 } 37 }
38 38
39 public static void Dispose(params IDisposable[] objects) 39 public static void Dispose(params IDisposable[] objects) {
40 { 40 foreach (var d in objects)
41 foreach(var d in objects)
42 if (d != null) 41 if (d != null)
43 d.Dispose(); 42 d.Dispose();
43 }
44
45 public static void Dispose(params object[] objects) {
46 foreach (var obj in objects) {
47 var d = obj as IDisposable;
48 if (d != null)
49 d.Dispose();
50 }
51 }
52
53 public static void Dispose(object obj) {
54 var d = obj as IDisposable;
55 if (d != null)
56 d.Dispose();
44 } 57 }
45 58
46 [DebuggerStepThrough] 59 [DebuggerStepThrough]
47 public static IPromise<T> InvokePromise<T>(Func<T> action) { 60 public static IPromise<T> InvokePromise<T>(Func<T> action) {
48 ArgumentNotNull(action, "action"); 61 ArgumentNotNull(action, "action");