# HG changeset patch # User cin # Date 2015-02-07 08:06:42 # Node ID b5c2d609d71b8c8249a08efad52cf292b295a399 # Parent 671f60cd0250319594901aa43a488dd8a70dba60 minor changes 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");