public RiakResult <IEnumerable <TResult> > UseDelayedConnection <TResult>(Func <IRiakConnection, Action, RiakResult <IEnumerable <TResult> > > useFun) where TResult : RiakResult { if (_disposing) { return(RiakResult <IEnumerable <TResult> > .Error(ResultCode.ShuttingDown, "Connection is shutting down", true)); } var response = _connections.DelayedConsume(useFun); if (response.Item1) { return(response.Item2); } return(RiakResult <IEnumerable <TResult> > .Error(ResultCode.NoConnections, "Unable to acquire connection", true)); }
public Task <RiakResult <IEnumerable <TResult> > > UseDelayedConnection <TResult>(Func <IRiakConnection, Action, Task <RiakResult <IEnumerable <TResult> > > > useFun) where TResult : RiakResult { if (_disposing) { return(TaskResult(RiakResult <IEnumerable <TResult> > .Error(ResultCode.ShuttingDown, "Connection is shutting down", true))); } // attempt consume return(_connections.DelayedConsume(useFun) .ContinueWith((Task <Tuple <bool, RiakResult <IEnumerable <TResult> > > > finishedTask) => { var result = finishedTask.Result; if (result.Item1) { return result.Item2; } return RiakResult <IEnumerable <TResult> > .Error(ResultCode.NoConnections, "Unable to acquire connection", true); })); }