private void doResolve(exec fn) { bool done = false; var res = tryCallTwo ( fn, value => { if (done) { return; } done = true; resolve(value); }, reason => { if (done) { return; } done = true; reject(reason); }); if (!done && res == IS_ERROR) { done = true; reject(LAST_ERROR); } }
public multi(string line) { //先分割成多個 basic string[] parts = line.Split(';'); basics = new IRunnable[parts.Length]; //然後就每一個 basic 進行分類 for (int i = 0; i < parts.Length; i++) { if (IsComment(parts[i])) { basics[i] = new empty(); } else if (IsTerm(parts[i])) { basics[i] = new term(parts[i].Trim()); } else if (IsExec(parts[i])) { basics[i] = new exec(parts[i].Trim()); } else { basics[i] = new decla(parts[i].Trim()); } } }
public static void Main() { int s = 0; exec e1 = new exec(); s = e1.execute((x => 2 * x), 3); Contract.Assert(s == 5); }
Mecanismo ( exec ex ) { this.ex = ex; }
public Promise(exec fn) { this._state = State._0_pending; this._value = null; this._handlers = null; if (fn == noop) { return; } doResolve(fn); }
private object tryCallTwo(exec fn, CB a, CB b) { try { fn(a, b); return(null); } catch (Exception ex) { LAST_ERROR = ex; return(IS_ERROR); } }
Mecanismo(exec ex) { this.ex = ex; }