leandrosa81 / taskbar-monitor

monitoring tool with graphs (CPU, memory, disk and network) for Windows taskbar.
https://lugarinho.tech/tools/taskbar-monitor
GNU General Public License v3.0
279 stars 24 forks source link

Unhandled exception after waking from hibernate #10

Closed SimoFiuz closed 2 years ago

SimoFiuz commented 3 years ago

After waking my laptop from sleep, I got the following:

System.InvalidOperationException: L'istanza 'Generic Mobile Broadband Adapter _10' non esiste nella categoria specificata.
   in System.Diagnostics.CounterDefinitionSample.GetInstanceValue(String instanceName)
   in System.Diagnostics.PerformanceCounter.NextSample()
   in System.Diagnostics.PerformanceCounter.NextValue()
   in TaskbarMonitor.Counters.CounterNetwork.Update()
   in TaskbarMonitor.SystemWatcherControl.timer1_Tick(Object sender, EventArgs e)
   in System.Windows.Forms.Timer.OnTick(EventArgs e)
   in System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   in System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Basically it says it can't find the broadband adapter. The code threw an unhandled exception not allowing me to do anything else besides killing explorer. My guess after a quick peek at the source is that for some slow (?) to respond hardware the enumeration in TaskbarMonitor.Counters.Update() still tries to access some counter no more existing in itsList<PerformanceCounter> netCountersSent ; I'll try to reproduce the issue while debugging.

leandrosa81 commented 3 years ago

Thank you for your report. I will add some code to handle this exception and collect new counters again when it happens.

SimoFiuz commented 3 years ago

I ran the software in debug in visual studio for a couple of minutes and then closed my laptop's lid but at wake up it raised no exception. Maybe I need it to go in deep sleep or something. I'll try again tonight. Anyway that section needs some exception handling for sure. Thanks Leandro.

leandrosa81 commented 3 years ago

I have just committed some code to try and fix this problem. If you are successful reproducing the problem, could you pull the latest source and retry to see if the bug is gone? I will try it too with my laptop this afternoon.

SimoFiuz commented 3 years ago

Sure!

leandrosa81 commented 3 years ago

This problem should go away on this new version 0.3.3, let me know if it still persists, please.

SimoFiuz commented 3 years ago

I will and thanks again.