public async Task UpdateStateAsync <TModel>(ResourceConfig <TModel> config) where TModel : class { var model = _Target.Get(config); if (model != null) { await _OperationContext.GetOrAdd( config, async() => { // wait for all dependencies var tasks = config .GetResourceDependencies() .Select(UpdateStateAsyncDispatch); await Task.WhenAll(tasks); // call the CreateOrUpdateAsync function for the resource. if (await _ShouldProcess.ShouldCreate(config, model)) { _ProgressReport.Start(config); var result = await config.CreateOrUpdateAsync( _OperationContext.Client, model, _OperationContext.CancellationToken); _ProgressReport.Done(config, _ProgressMap.Get(config)); return(result); } else { return(null); } }); } }