public void GetElementData(Guid elementId, string key) { var data = GenericData.GetPlaceData(elementId, key); Response.BodyWriter.WriteAsync(data); Response.CompleteAsync(); return; }
public void IncrementElementData(Guid elementId, string key, double changeAmount, double?expirationTimer = null) { PerformanceTracker pt = new PerformanceTracker("IncrementElementData"); string lockKey = elementId.ToString() + key; locks.TryAdd(lockKey, new ReaderWriterLockSlim()); var thisLock = locks[lockKey]; thisLock.EnterWriteLock(); var data = GenericData.GetPlaceData(elementId, key); double val = 0; Double.TryParse(data.ToString(), out val); val += changeAmount; GenericData.SetPlaceData(elementId, key, val.ToString(), expirationTimer); thisLock.ExitWriteLock(); if (thisLock.WaitingWriteCount == 0) { locks.TryRemove(lockKey, out thisLock); } pt.Stop(); }