public async Task <IList <INumericRangeBlockContext> > GetNumericRangeBlocksAsync(Func <IFluentNumericRangeBlockDescriptor, object> fluentBlockRequest) { if (!IsExecutionContextActive) { throw new ExecutionException(NotActiveMessage); } var fluentDescriptor = fluentBlockRequest(new FluentRangeBlockDescriptor()); var settings = (IBlockSettings)fluentDescriptor; var request = ConvertToNumericRangeBlockRequest(settings); if (ShouldProtect(request)) { var csContext = CreateClientCriticalSection(); try { var csStarted = await csContext.TryStartAsync(new TimeSpan(0, 0, 20), 3).ConfigureAwait(false); if (csStarted) { return(await _blockFactory.GenerateNumericRangeBlocksAsync(request).ConfigureAwait(false)); } throw new CriticalSectionException("Could not start a critical section in the alloted time"); } finally { await csContext.CompleteAsync().ConfigureAwait(false); } } else { return(await _blockFactory.GenerateNumericRangeBlocksAsync(request).ConfigureAwait(false)); } }