From 17471285e3b1b317294f20e5192c5d7562ccc7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= Date: Wed, 4 Nov 2020 18:13:47 +0100 Subject: [PATCH] Fix error check. (#324) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case when the interface is removed (File Not Found error), the value of NativeErrorCode is 2, while the value of HResult is 0x80004005. Signed-off-by: Oldřich Jedlička --- LibreHardwareMonitorLib/Hardware/Network/Network.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibreHardwareMonitorLib/Hardware/Network/Network.cs b/LibreHardwareMonitorLib/Hardware/Network/Network.cs index 63de642..c77be5f 100644 --- a/LibreHardwareMonitorLib/Hardware/Network/Network.cs +++ b/LibreHardwareMonitorLib/Hardware/Network/Network.cs @@ -98,7 +98,7 @@ namespace LibreHardwareMonitor.Hardware.Network _bytesDownloaded = interfaceStats.BytesReceived; _lastTick = newTick; } - catch (NetworkInformationException networkInformationException) when (unchecked(networkInformationException.NativeErrorCode == (int)0x80004005)) + catch (NetworkInformationException networkInformationException) when (unchecked(networkInformationException.HResult == (int)0x80004005)) { foreach (NetworkInterface networkInterface in NetworkInterface.GetAllNetworkInterfaces()) {