diff --git a/Implab/Safe.cs b/Implab/Safe.cs --- a/Implab/Safe.cs +++ b/Implab/Safe.cs @@ -86,6 +86,21 @@ namespace Implab } [DebuggerStepThrough] + public static IPromise InvokePromise(Func action) { + ArgumentNotNull(action, "action"); + + var p = new Promise(); + try { + action(); + p.Resolve(); + } catch (Exception err) { + p.Reject(err); + } + + return p; + } + + [DebuggerStepThrough] public static IPromise InvokePromise(Func> action) { ArgumentNotNull(action, "action");