兼容win7版应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
739 B

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
namespace AIK.Common
{
public static class GlobalImageCache
{
private static readonly ConcurrentDictionary<string, BitmapImage> _imgListKey = new ConcurrentDictionary<string, BitmapImage>();
public static BitmapImage GetOrAdd(string url, Func<string, BitmapImage> valueFactory)
{
return _imgListKey.GetOrAdd(url, valueFactory);
}
public static bool TryGetValue(string key, out BitmapImage value)
{
return _imgListKey.TryGetValue(key, out value);
}
}
}