Mercurial > pub > ImplabNet
comparison Implab/Safe.cs @ 94:a43745f81f10 v2
minor fixes
author | cin |
---|---|
date | Thu, 23 Oct 2014 17:50:09 +0400 |
parents | efcb076407a7 |
children | 0141a165d032 |
comparison
equal
deleted
inserted
replaced
93:dc4942d09e74 | 94:a43745f81f10 |
---|---|
42 if (disp != null) | 42 if (disp != null) |
43 disp.Dispose(); | 43 disp.Dispose(); |
44 } | 44 } |
45 | 45 |
46 [DebuggerStepThrough] | 46 [DebuggerStepThrough] |
47 public static IPromise<T> GuargPromise<T>(Func<T> action) { | 47 public static IPromise<T> InvokePromise<T>(Func<T> action) { |
48 ArgumentNotNull(action, "action"); | 48 ArgumentNotNull(action, "action"); |
49 | 49 |
50 var p = new Promise<T>(); | 50 var p = new Promise<T>(); |
51 try { | 51 try { |
52 p.Resolve(action()); | 52 p.Resolve(action()); |
56 | 56 |
57 return p; | 57 return p; |
58 } | 58 } |
59 | 59 |
60 [DebuggerStepThrough] | 60 [DebuggerStepThrough] |
61 public static IPromise<T> GuardPromise<T>(Func<IPromise<T>> action) { | 61 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { |
62 ArgumentNotNull(action, "action"); | 62 ArgumentNotNull(action, "action"); |
63 | 63 |
64 try { | 64 try { |
65 return action(); | 65 return action() ?? Promise<T>.ExceptionToPromise(new Exception("The action returned null")); |
66 } catch (Exception err) { | 66 } catch (Exception err) { |
67 return Promise<T>.ExceptionToPromise(err); | 67 return Promise<T>.ExceptionToPromise(err); |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |