public DeviceRepository() { if (DeviceCache.Count == 0) { lock (lockObject) { if (DeviceCache.Count == 0) { LoadDevices().ToList().ForEach(x => DeviceCache.TryAdd(x.Name, x)); } } } }