Ejemplo n.º 1
0
 void sinkTimer(long t)
 {
     if (MyIsolator == null)
     {
         return;
     }
     if (MyIsolator.HasExited)
     {
         TheQueuedSenderRegistry.UnregisterHealthTimer(sinkTimer);
         MyBaseThing.StatusLevel = 0;
         MyBaseThing.LastMessage = "Plugin no longer running";
         return;
     }
     try
     {
         TheThing.SetSafePropertyString(MyBaseThing, "IORead", string.Format("{0:0.00}", readBytesSec?.NextValue()));
         //if ((t%15)!=0) return;
         TheThing.SetSafePropertyString(MyBaseThing, "CPUTime", string.Format("{0:0.00}", MyIsolator.TotalProcessorTime.TotalSeconds));
         TheThing.SetSafePropertyNumber(MyBaseThing, "WorkingSet", MyIsolator.WorkingSet64 / 1024);
         TheThing.SetSafePropertyNumber(MyBaseThing, "Handles", MyIsolator.HandleCount);
         TheThing.SetSafePropertyNumber(MyBaseThing, "Threads", MyIsolator.Threads.Count);
         TimeSpan ts = DateTime.Now.Subtract(MyIsolator.StartTime);
         TheThing.SetSafePropertyNumber(MyBaseThing, "UpTime", ts.TotalMinutes);
         using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", $"SELECT * FROM Win32_PerfFormattedData_PerfProc_Process where IDProcess='{MyIsolator.Id}'"))
         {
             foreach (ManagementObject queryObj in searcher.Get())
             {
                 TheThing.SetSafePropertyString(MyBaseThing, "CPU", queryObj["PercentProcessorTime"].ToString());
                 MyBaseThing.Value = queryObj["PercentProcessorTime"].ToString();
                 //foreach (var ttt in queryObj.Properties)
                 //{
                 //    Console.WriteLine($"{ttt.Name}: {ttt.Value}");
                 //}
             }
         }
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 2
0
 public void Disconnect()
 {
     TheQueuedSenderRegistry.UnregisterHealthTimer(sinkTimer);
     TheThing.SetSafePropertyBool(MyBaseThing, "IsConnected", false);
 }