/// <summary> /// Update entry in the configuration. /// </summary> /// <param name="key">key of the entry.</param> /// <param name="value">value to use when updating.</param> /// <returns>boolean of success/failure.</returns> public bool Update(IConfigItem configItem) { if (!_memoryCacheService.Contains(configItem.key)) { throw new KeyNotFoundException(string.Format("Configuration key not found {0}", configItem.key)); } if (Monitor.TryEnter(_lockObject)) { try { Thread.Sleep(5000); _memoryCacheService.Update(configItem); _fileManager.UpdateEntry(configItem); } catch (Exception e) { _memoryCacheService.Reset(configItem.key); throw new ConfigUpdateException(string.Format("Configuration update failed for key {0}", configItem.key)); } finally { Monitor.Exit(_lockObject); } } else { throw new ResourceLockedException(string.Format("Resource locked while updating config item {0}", configItem.key)); } return(true); }