diff --git a/Helper/File/IconReader.cs b/Helper/File/IconReader.cs index eaf5a4c..1cc0ea4 100644 --- a/Helper/File/IconReader.cs +++ b/Helper/File/IconReader.cs @@ -1,5 +1,6 @@ using Clearcove.Logging; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Drawing; using System.IO; @@ -19,8 +20,7 @@ namespace SystemTrayMenu.Helper /// public class IconReader { - static Dictionary dictIconCache = new Dictionary(); - static readonly object lockIconCache = new object(); + static ConcurrentDictionary dictIconCache = new ConcurrentDictionary(); /// /// Options to specify the size of icons to return. @@ -65,7 +65,7 @@ namespace SystemTrayMenu.Helper { bool isExtensionWitSameIcon = true; List extensionsWithDiffIcons = new List - { ".exe", ".ink", ".ico", ".url" }; + { ".exe", ".lnk", ".ico", ".url" }; if (extensionsWithDiffIcons.Contains(fileExtension.ToLower())) { isExtensionWitSameIcon = false; @@ -75,17 +75,10 @@ namespace SystemTrayMenu.Helper if (IsExtensionWitSameIcon(extension)) { - lock (lockIconCache) + icon = dictIconCache.GetOrAdd(extension, GetIcon); + Icon GetIcon(string keyExtension) { - if (dictIconCache.ContainsKey(extension)) - { - icon = dictIconCache[extension]; - } - else - { - icon = GetFileIcon(filePath, linkOverlay, size); - dictIconCache.Add(extension, icon); - } + return GetFileIcon(filePath, linkOverlay, size); } } else @@ -95,6 +88,7 @@ namespace SystemTrayMenu.Helper return icon; } + private static Icon GetFileIcon(string filePath, bool linkOverlay, IconSize size = IconSize.Small) { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 8e16864..3bab3fa 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("TAMAHO")] [assembly: AssemblyProduct("TAMAHO SystemTrayMenu")] -[assembly: AssemblyCopyright("Copyright © 2019, TAMAHO SystemTrayMenu")] +[assembly: AssemblyCopyright("Copyright © 2020, TAMAHO SystemTrayMenu")] [assembly: AssemblyTrademark("TAMAHO")] [assembly: AssemblyCulture("")] @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.9.2.0")] -[assembly: AssemblyFileVersion("0.9.2.0")] +[assembly: AssemblyVersion("0.9.2.1")] +[assembly: AssemblyFileVersion("0.9.2.1")]