diff Implab/Safe.cs @ 95:0141a165d032 v2

minor changes
author cin
date Wed, 29 Oct 2014 18:54:46 +0300
parents a43745f81f10
children daffa72a1cec
line wrap: on
line diff
--- a/Implab/Safe.cs	Thu Oct 23 17:50:09 2014 +0400
+++ b/Implab/Safe.cs	Wed Oct 29 18:54:46 2014 +0300
@@ -58,6 +58,21 @@
         }
 
         [DebuggerStepThrough]
+        public static IPromise<T> InvokePromise<T>(Action action) {
+            ArgumentNotNull(action, "action");
+
+            var p = new Promise<object>();
+            try {
+                action();
+                p.Resolve();
+            } catch (Exception err) {
+                p.Reject(err);
+            }
+
+            return p;
+        }
+
+        [DebuggerStepThrough]
         public static IPromise<T> InvokePromise<T>(Func<IPromise<T>> action) {
             ArgumentNotNull(action, "action");