Example #1
0
            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);
                }
            }