Mercurial > pub > ImplabNet
comparison Implab/Safe.cs @ 131:b5c2d609d71b v2
minor changes
author | cin |
---|---|
date | Sat, 07 Feb 2015 11:06:42 +0300 |
parents | 6241bff0cd64 |
children | 5fb2bbffdece |
comparison
equal
deleted
inserted
replaced
130:671f60cd0250 | 131:b5c2d609d71b |
---|---|
84 | 84 |
85 return p; | 85 return p; |
86 } | 86 } |
87 | 87 |
88 [DebuggerStepThrough] | 88 [DebuggerStepThrough] |
89 public static IPromise InvokePromise(Func<IPromise> action) { | |
90 ArgumentNotNull(action, "action"); | |
91 | |
92 var p = new Promise(); | |
93 try { | |
94 action(); | |
95 p.Resolve(); | |
96 } catch (Exception err) { | |
97 p.Reject(err); | |
98 } | |
99 | |
100 return p; | |
101 } | |
102 | |
103 [DebuggerStepThrough] | |
89 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { | 104 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { |
90 ArgumentNotNull(action, "action"); | 105 ArgumentNotNull(action, "action"); |
91 | 106 |
92 try { | 107 try { |
93 return action() ?? Promise<T>.ExceptionToPromise(new Exception("The action returned null")); | 108 return action() ?? Promise<T>.ExceptionToPromise(new Exception("The action returned null")); |