Mercurial > pub > ImplabNet
comparison Implab/Safe.cs @ 95:0141a165d032 v2
minor changes
author | cin |
---|---|
date | Wed, 29 Oct 2014 18:54:46 +0300 |
parents | a43745f81f10 |
children | daffa72a1cec |
comparison
equal
deleted
inserted
replaced
94:a43745f81f10 | 95:0141a165d032 |
---|---|
56 | 56 |
57 return p; | 57 return p; |
58 } | 58 } |
59 | 59 |
60 [DebuggerStepThrough] | 60 [DebuggerStepThrough] |
61 public static IPromise<T> InvokePromise<T>(Action action) { | |
62 ArgumentNotNull(action, "action"); | |
63 | |
64 var p = new Promise<object>(); | |
65 try { | |
66 action(); | |
67 p.Resolve(); | |
68 } catch (Exception err) { | |
69 p.Reject(err); | |
70 } | |
71 | |
72 return p; | |
73 } | |
74 | |
75 [DebuggerStepThrough] | |
61 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { | 76 public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) { |
62 ArgumentNotNull(action, "action"); | 77 ArgumentNotNull(action, "action"); |
63 | 78 |
64 try { | 79 try { |
65 return action() ?? Promise<T>.ExceptionToPromise(new Exception("The action returned null")); | 80 return action() ?? Promise<T>.ExceptionToPromise(new Exception("The action returned null")); |