コード例 #1
0
        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;
                    }
                }
            }
        }
コード例 #2
0
 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;
         }
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public static IPromise JoinSerial <T>(this IEnumerable <IPromise <T> > items, PromiseFactory factory)
 {
     return(factory.JoinSerial(items));
 }
コード例 #5
0
 public static IPromise JoinParallel(this IEnumerable <IPromise> items, PromiseFactory factory)
 {
     return(factory.JoinParallel(items));
 }
コード例 #6
0
 public static IPromiseEnumerable <T> Promesify <T>(this IEnumerable <T> items, PromiseFactory factory)
 {
     return(new PromiseEnumerable <T>(factory, items));
 }
コード例 #7
0
 public PromiseSynchronizationContext(PromiseFactory factory)
 {
     this._factory  = factory;
     this._last     = null;
     this._syncRoot = new object();
 }
コード例 #8
0
 public Promise(PromiseFactory factory, Action promise)
     : this(factory, promise, PromisePriority.Normal)
 {
 }
コード例 #9
0
 public Promise(PromiseFactory factory, Action promise, PromisePriority priority)
 {
     _promise = factory.StartNew(promise, priority);
 }
コード例 #10
0
 public Promise(PromiseFactory factory, Action <Action, Action <Exception> > promise)
     : this(factory, promise, PromisePriority.Normal)
 {
 }
コード例 #11
0
 public static PromiseSynchronizationContext CreateSynchronizationContext(PromiseFactory factory)
 {
     return(new PromiseSynchronizationContext(factory));
 }
コード例 #12
0
 public static IPromiseEnumerable <T> Enumerable <T>(PromiseFactory factory, IEnumerable <T> items)
 {
     return(new PromiseEnumerable <T>(factory, items));
 }