Fix 8 second UI freeze when changing Windows display scale percentage (#249)

* Try modifying existing icon before attempting add

* Prevent setting _created to false if already created and Modify fails

* Remove variable

Co-authored-by: Campbell Harding-Deason <campbell@alarmnz.com>
This commit is contained in:
Campbell
2020-05-18 10:42:11 +02:00
committed by GitHub
co-authored by Campbell Harding-Deason
parent 3cc3d9139c
commit b059f98285
+15 -8
View File
@@ -599,16 +599,23 @@ namespace LibreHardwareMonitor.UI
{
if (!_created)
{
int i = 0;
do
if (NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Modify, data))
{
_created = NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Add, data);
if (!_created)
_created = true;
}
else
{
int i = 0;
do
{
System.Threading.Thread.Sleep(200);
i++;
}
} while (!_created && i < 40);
_created = NativeMethods.Shell_NotifyIcon(NativeMethods.NotifyIconMessage.Add, data);
if (!_created)
{
System.Threading.Thread.Sleep(200);
i++;
}
} while (!_created && i < 40);
}
}
else
{