예제 #1
0
            public Logic(TaskCompletionSource <T> promise, FirstOrDefaultStage <T> stage) : base(stage.Shape)
            {
                _promise = promise;
                _stage   = stage;

                SetHandler(stage.In, this);
            }
예제 #2
0
            public Logic(TaskCompletionSource <T> promise, FirstOrDefaultStage <T> stage) : base(stage.Shape)
            {
                _stage = stage;

                SetHandler(stage.In, onPush: () =>
                {
                    promise.TrySetResult(Grab(stage.In));
                    CompleteStage();
                },
                           onUpstreamFinish: () =>
                {
                    promise.TrySetResult(default(T));
                    CompleteStage();
                },
                           onUpstreamFailure: cause =>
                {
                    promise.TrySetException(cause);
                    FailStage(cause);
                });
            }