private ContourTileData GetContourTileData(ContourQuery contourQuery)
    {
        string key = new ConnectionStringParser().ComposeConnectionString(contourQuery);
        ContourTileData contourTileData = new ContourTileData();
        CacheItemPolicy cacheItemPolicy = new CacheItemPolicy() { SlidingExpiration = TimeSpan.FromMinutes(1) };

        contourTileData = (ContourTileData)s_contourDataCache.AddOrGetExisting(key, contourTileData, cacheItemPolicy) ?? contourTileData;

        if ((object)contourTileData.IDWFunction != null && (object)contourTileData.ColorFunction != null)
            return contourTileData;

        using (ManualResetEvent waitHandle = new ManualResetEvent(false))
        {
            ManualResetEvent cachedWaitHandle = Interlocked.CompareExchange(ref contourTileData.WaitHandle, waitHandle, null);

            try
            {
                try
                {
                    if ((object)cachedWaitHandle != null)
                    {
                        cachedWaitHandle.WaitOne();
                        return contourTileData;
                    }
                }
                catch (ObjectDisposedException)
                {
                    return contourTileData;
                }

                List<TrendingDataLocation> locations = GetFrameFromDailySummary(contourQuery);
                Func<double, double> colorFunction = GetColorScale(contourQuery);
                IDWFunc idwFunction = GetIDWFunction(contourQuery, locations);

                contourTileData.MinLatitude = locations.Min(location => location.Latitude) - GetLatFromMiles(50.0D);
                contourTileData.MaxLatitude = locations.Max(location => location.Latitude) + GetLatFromMiles(50.0D);
                contourTileData.MinLongitude = locations.Min(location => location.Longitude) - GetLngFromMiles(50.0D, 0.0D);
                contourTileData.MaxLongitude = locations.Max(location => location.Longitude) + GetLngFromMiles(50.0D, 0.0D);

                contourTileData.IDWFunction = idwFunction;
                contourTileData.ColorFunction = colorFunction;

                return contourTileData;
            }
            finally
            {
                waitHandle.Set();
            }
        }
    }
 /// <summary>
 /// Creates a new instance of the <see cref="SystemSettings"/> class.
 /// </summary>
 /// <param name="connectionString">A string containing the system settings as key-value pairs.</param>
 public SystemSettings(string connectionString)
 {
     ConnectionStringParser<SettingAttribute> parser = new ConnectionStringParser<SettingAttribute>();
     parser.ParseConnectionString(connectionString, this);
 }
 public string ToConnectionString()
 {
     ConnectionStringParser<SettingAttribute> parser = new ConnectionStringParser<SettingAttribute>();
     parser.ExplicitlySpecifyDefaults = true;
     return parser.ComposeConnectionString(this);
 }
 /// <summary>
 /// Creates a new instance of the <see cref="FileShare"/> class.
 /// </summary>
 /// <param name="connectionString">A string containing the file share parameters as key-value pairs.</param>
 public FileShare(string connectionString)
 {
     ConnectionStringParser<SettingAttribute> parser = new ConnectionStringParser<SettingAttribute>();
     parser.ParseConnectionString(connectionString, this);
 }