Mercurial > pub > ImplabNet
comparison Implab/Safe.cs @ 119:2573b562e328 v2
Promises rewritten, added improved version of AsyncQueue
author | cin |
---|---|
date | Sun, 11 Jan 2015 19:13:02 +0300 |
parents | daffa72a1cec |
children | 62d2f1e98c4e |
comparison
equal
deleted
inserted
replaced
118:e046a94eecb1 | 119:2573b562e328 |
---|---|
21 throw new ArgumentException("The parameter can't be empty", name); | 21 throw new ArgumentException("The parameter can't be empty", name); |
22 } | 22 } |
23 | 23 |
24 public static void ArgumentNotEmpty<T>(T[] param, string name) { | 24 public static void ArgumentNotEmpty<T>(T[] param, string name) { |
25 if (param == null || param.Length == 0) | 25 if (param == null || param.Length == 0) |
26 throw new ArgumentException("The array must be not emty"); | 26 throw new ArgumentException("The array must be not emty", name); |
27 } | 27 } |
28 | 28 |
29 public static void ArgumentNotNull(object param, string name) { | 29 public static void ArgumentNotNull(object param, string name) { |
30 if (param == null) | 30 if (param == null) |
31 throw new ArgumentNullException(name); | 31 throw new ArgumentNullException(name); |
59 | 59 |
60 [DebuggerStepThrough] | 60 [DebuggerStepThrough] |
61 public static IPromise InvokePromise(Action action) { | 61 public static IPromise InvokePromise(Action action) { |
62 ArgumentNotNull(action, "action"); | 62 ArgumentNotNull(action, "action"); |
63 | 63 |
64 var p = new Promise<object>(); | 64 var p = new Promise(); |
65 try { | 65 try { |
66 action(); | 66 action(); |
67 p.Resolve(); | 67 p.Resolve(); |
68 } catch (Exception err) { | 68 } catch (Exception err) { |
69 p.Reject(err); | 69 p.Reject(err); |