private void CacheData(GraphDataProperties properties, int index) { var data = CreateOrGet(properties); lock (_requestLock) { if (properties.Equals((object)_requested)) { _callback(data); _requested = null; _callback = null; } } }
public bool TryGet(SrmDocument document, AreaCVGraphSettings settings, Action <AreaCVGraphData> callback, out AreaCVGraphData result) { var properties = new GraphDataProperties(settings); if (!IsValidFor(document, settings)) { Cancel(); lock (_cacheInfo) { _cacheInfo.Clear(); _cacheInfo.Document = document; _cacheInfo.Settings = settings; } // Get a list of all properties that we want to cache data for, except for the data that just got requested var propertyList = new List <GraphDataProperties>(GetPropertyVariants(settings).Except(new[] { properties })); _producerConsumer.Add(propertyList, false, false); } result = Get(properties); if (result != null) { return(true); } lock (_requestLock) { if (!properties.Equals((object)_requested)) { _producerConsumer.Add(properties); _requested = properties; _callback = callback; } return(false); } }