mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-17 09:55:20 +12:00
This commit is contained in:
parent
56ba365909
commit
15cf58c28c
|
@ -9,7 +9,7 @@
|
||||||
<Identity
|
<Identity
|
||||||
Name="49543SystemTrayMenu.SystemTrayMenu"
|
Name="49543SystemTrayMenu.SystemTrayMenu"
|
||||||
Publisher="CN=5884501C-92ED-45DE-9508-9D987C314243"
|
Publisher="CN=5884501C-92ED-45DE-9508-9D987C314243"
|
||||||
Version="1.0.21.0" />
|
Version="1.0.22.0" />
|
||||||
|
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>SystemTrayMenu</DisplayName>
|
<DisplayName>SystemTrayMenu</DisplayName>
|
||||||
|
|
|
@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.22.0")]
|
[assembly: AssemblyVersion("1.0.22.1")]
|
||||||
[assembly: AssemblyFileVersion("1.0.22.0")]
|
[assembly: AssemblyFileVersion("1.0.22.1")]
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace SystemTrayMenu.Utilities
|
||||||
private static readonly ConcurrentDictionary<string, Icon> DictIconCache = new ConcurrentDictionary<string, Icon>();
|
private static readonly ConcurrentDictionary<string, Icon> DictIconCache = new ConcurrentDictionary<string, Icon>();
|
||||||
private static readonly Icon LoadingIcon = Properties.Resources.Loading;
|
private static readonly Icon LoadingIcon = Properties.Resources.Loading;
|
||||||
|
|
||||||
// private static readonly object ReadIcon = new object();
|
|
||||||
public enum IconSize
|
public enum IconSize
|
||||||
{
|
{
|
||||||
Large = 0, // 32x32 pixels
|
Large = 0, // 32x32 pixels
|
||||||
|
@ -38,6 +37,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
Closed = 1,
|
Closed = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see https://github.com/Hofknecht/SystemTrayMenu/issues/209.
|
||||||
public static bool SingleThread { get; set; }
|
public static bool SingleThread { get; set; }
|
||||||
|
|
||||||
public static void Dispose()
|
public static void Dispose()
|
||||||
|
@ -74,6 +74,8 @@ namespace SystemTrayMenu.Utilities
|
||||||
key = extension + linkOverlay;
|
key = extension + linkOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClearBadIcons();
|
||||||
|
|
||||||
if (!DictIconCache.TryGetValue(key, out Icon icon))
|
if (!DictIconCache.TryGetValue(key, out Icon icon))
|
||||||
{
|
{
|
||||||
icon = LoadingIcon;
|
icon = LoadingIcon;
|
||||||
|
@ -154,6 +156,8 @@ namespace SystemTrayMenu.Utilities
|
||||||
key = extension + linkOverlay;
|
key = extension + linkOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClearBadIcons();
|
||||||
|
|
||||||
if (!DictIconCache.TryGetValue(key, out Icon icon))
|
if (!DictIconCache.TryGetValue(key, out Icon icon))
|
||||||
{
|
{
|
||||||
icon = LoadingIcon;
|
icon = LoadingIcon;
|
||||||
|
@ -210,6 +214,8 @@ namespace SystemTrayMenu.Utilities
|
||||||
|
|
||||||
string key = path;
|
string key = path;
|
||||||
|
|
||||||
|
ClearBadIcons();
|
||||||
|
|
||||||
if (!DictIconCache.TryGetValue(key, out Icon icon))
|
if (!DictIconCache.TryGetValue(key, out Icon icon))
|
||||||
{
|
{
|
||||||
icon = LoadingIcon;
|
icon = LoadingIcon;
|
||||||
|
@ -351,6 +357,21 @@ namespace SystemTrayMenu.Utilities
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clear icons which are null.
|
||||||
|
/// see https://github.com/Hofknecht/SystemTrayMenu/issues/209.
|
||||||
|
/// This only happens with the MainPreload method. SingleThread had only partially solved it before.
|
||||||
|
/// It is unclear exactly where the problem comes from, because it never seems to be null later.
|
||||||
|
/// </summary>
|
||||||
|
private static void ClearBadIcons()
|
||||||
|
{
|
||||||
|
IEnumerable<string> badKeysList = DictIconCache.Where(x => x.Value == null).Select(x => x.Key);
|
||||||
|
foreach (string badKey in badKeysList)
|
||||||
|
{
|
||||||
|
DictIconCache.Remove(badKey, out _);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static bool IsExtensionWithSameIcon(string fileExtension)
|
private static bool IsExtensionWithSameIcon(string fileExtension)
|
||||||
{
|
{
|
||||||
bool isExtensionWithSameIcon = true;
|
bool isExtensionWithSameIcon = true;
|
||||||
|
|
Loading…
Reference in a new issue