public static void SetDefaultFactory(PromiseBackend backend) { lock (_syncRoot) { if (_factory == null) { _factory = new PromiseFactory(backend); _backend = null; if (backend == PromiseBackend.Default) { _backendType = PromiseFactory.DefaultBackend; } else { _backendType = backend; } } else if (_backend != null) { _factory.Dispose(); _factory = new PromiseFactory(backend); _backend = null; if (backend == PromiseBackend.Default) { _backendType = PromiseFactory.DefaultBackend; } else { _backendType = backend; } } else if (_backendType != backend) { _factory.Dispose(); _factory = new PromiseFactory(backend); if (backend == PromiseBackend.Default) { _backendType = PromiseFactory.DefaultBackend; } else { _backendType = backend; } } } }
public static void SetDefaultFactory(IBackend backend) { lock (_syncRoot) { if (_factory == null) { _factory = new PromiseFactory(backend); _backend = backend; } else if (!Object.Equals(_backend, backend)) { _factory.Dispose(); _factory = new PromiseFactory(backend); _backend = backend; } } }
public Promise(PromiseFactory factory, Action <Action, Action <Exception> > promise, PromisePriority priority) { _promise = factory.StartNew(() => { Exception error = null; bool hasError = false; promise(() => { error = null; hasError = false; }, x => { error = x; hasError = true; }); if (hasError) { throw error; } }, priority); }
public static IPromise JoinSerial <T>(this IEnumerable <IPromise <T> > items, PromiseFactory factory) { return(factory.JoinSerial(items)); }
public static IPromise JoinParallel(this IEnumerable <IPromise> items, PromiseFactory factory) { return(factory.JoinParallel(items)); }
public static IPromiseEnumerable <T> Promesify <T>(this IEnumerable <T> items, PromiseFactory factory) { return(new PromiseEnumerable <T>(factory, items)); }
public PromiseSynchronizationContext(PromiseFactory factory) { this._factory = factory; this._last = null; this._syncRoot = new object(); }
public Promise(PromiseFactory factory, Action promise) : this(factory, promise, PromisePriority.Normal) { }
public Promise(PromiseFactory factory, Action promise, PromisePriority priority) { _promise = factory.StartNew(promise, priority); }
public Promise(PromiseFactory factory, Action <Action, Action <Exception> > promise) : this(factory, promise, PromisePriority.Normal) { }
public static PromiseSynchronizationContext CreateSynchronizationContext(PromiseFactory factory) { return(new PromiseSynchronizationContext(factory)); }
public static IPromiseEnumerable <T> Enumerable <T>(PromiseFactory factory, IEnumerable <T> items) { return(new PromiseEnumerable <T>(factory, items)); }