Exemplo n.º 1
0
            public override void OnPull()
            {
                void Ready(TSource source)
                {
                    try
                    {
                        void Continune(Task <Option <TOut> > t)
                        {
                            if (!t.IsFaulted && !t.IsCanceled)
                            {
                                _createdCallback(new Left <Option <TOut>, Exception>(t.Result));
                            }
                            else
                            {
                                _createdCallback(new Right <Option <TOut>, Exception>(t.Exception));
                            }
                        }

                        _source._readData(source).ContinueWith(Continune);
                    }
                    catch (Exception ex)
                    {
                        ErrorHandler(ex);
                    }
                }

                OnResourceReady(Ready);
            }
Exemplo n.º 2
0
 public override void OnPull()
 {
     if (_state.HasValue)
     {
         try
         {
             var resource = _state.Value;
             _stage._readData(resource).OnComplete(ReadCallback);
         }
         catch (Exception ex)
         {
             ErrorHandler(ex);
         }
     }
     else
     {
         // we got a pull but there is no open resource, we are either
         // currently creating/restarting then the read will be triggered when creating the
         // resource completes, or shutting down and then the pull does not matter anyway
     }
 }
Exemplo n.º 3
0
 public override void OnPull()
 {
     OnResourceReady(source =>
     {
         try
         {
             _source._readData(source).ContinueWith(t =>
             {
                 if (t.IsCompleted && !t.IsCanceled)
                 {
                     _callback(new Left <Option <TOut>, Exception>(t.Result));
                 }
                 else
                 {
                     _callback(new Right <Option <TOut>, Exception>(t.Exception));
                 }
             });
         }
         catch (Exception ex)
         {
             ErrorHandler(ex);
         }
     });
 }