public static ImageSource Load(string path) { Logger.WoxDebug($"load begin {path}"); var img = _cache.GetOrAdd(path, LoadInternal); Logger.WoxTrace($"load end {path}"); return(img); }
private static ImageSource GetErrorImage() { ImageSource image = _cache.GetOrAdd(Constant.ErrorIcon, (_) => { BitmapImage bitmap = new BitmapImage(new Uri(Constant.ErrorIcon)) { DecodePixelHeight = 32, DecodePixelWidth = 32 }; bitmap.Freeze(); return(bitmap); }); return(image); }
public static ImageSource Load(string path) { Logger.WoxDebug($"load begin {path}"); var img = _cache.GetOrAdd(path, p => { try { return(LoadInternal(p)); } catch (Exception e) { e.Data.Add(nameof(p), p); Logger.WoxError($"cannot load image sync <{p}>", e); return(GetErrorImage()); } }); Logger.WoxTrace($"load end {path}"); return(img); }