Exemplo n.º 1
0
 void ObservePromise(Promise <T> promise)
 {
     promise.Done(deferred.Resolve);
     promise.Fail(t => {
         nonResolvedCount++;
         if (nonResolvedCount == size)
         {
             deferred.Dispose();
         }
     });
     promise.Disposed(() => {
         nonResolvedCount++;
         if (nonResolvedCount == size)
         {
             deferred.Dispose();
         }
     });
 }
Exemplo n.º 2
0
 public override void Dispose()
 {
     _deferred.Dispose();
     if (_socket != null)
     {
         _socket.Dispose();
     }
     base.Dispose();
 }
Exemplo n.º 3
0
        public override void OnEnteredForeground()
        {
            if (_socket != null)
            {
                _socket.Dispose();
                _socket = null;
            }

            _deffered.Dispose();

            ConnectWebsocket();

            CleanNotification();
        }
Exemplo n.º 4
0
        public void ExceptionThrownInDisposedShouldBeReportedToSinkExceptionHandler()
        {
            Promises.ResetSinkExceptionHandler(e => exceptions.Add(e));
            var source = new Deferred <TWrapper <int> > ();

            source.Disposed(() => {
                throw new Exception();
            });
            source.Disposed(() => {
                throw new Exception();
            });
            source.Dispose();
            source.Disposed(() => {
                throw new Exception();
            });
            source.Disposed(() => {
                throw new Exception();
            });
            Assert.That(exceptions.Count, Is.EqualTo(4));
        }
        protected override Promise <CUnit> DoHide()
        {
            animator.ResetTrigger("TriggerHide");
            animator.ResetTrigger("TriggerShow");
            animatorEventSubject.OnNext("Reset");

            var result = new Deferred <CUnit> ();

            animator.SetTrigger("TriggerHide");
            animatorEventSubject.Take(1).Subscribe(e => {
                if (e == "Hidden")
                {
                    result.Resolve(CUnit.Default);
                }
                else
                {
                    result.Dispose();
                }
            }).AddTo(this);
            result.Disposed(DoForceHide);
            return(result);
        }