public void AddSensor(string productName, SensorValueBase sensorValue) { var newObject = _converter.Convert(productName, sensorValue); lock (_dictionaryLock) { if (!_productSensorsDictionary.ContainsKey(productName)) { _productSensorsDictionary[productName] = new List <SensorInfo>(); } _productSensorsDictionary[productName].Add(newObject); } Task.Run(() => _databaseAdapter.AddSensor(newObject)); }