public async Task <IList <IObjectBlockContext <T> > > GetObjectBlocksAsync <T>(Func <IFluentObjectBlockDescriptorBase <T>, object> fluentBlockRequest) { if (!IsExecutionContextActive) { throw new ExecutionException(NotActiveMessage); } var fluentDescriptor = fluentBlockRequest(new FluentObjectBlockDescriptorBase <T>()); var settings = (IObjectBlockSettings <T>)fluentDescriptor; var request = ConvertToObjectBlockRequest(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.GenerateObjectBlocksAsync(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.GenerateObjectBlocksAsync(request).ConfigureAwait(false)); } }