public static void RunScript(CSharpScript s) { var trigger = new EventWaitHandle(false, EventResetMode.ManualReset); Exception ex = null; s.ScriptExecutionFinished += (sender, e) => { ex = e.Value; trigger.Set(); }; s.ExecuteAsync(); trigger.WaitOne(); Assert.IsNull(ex); }