Ejemplo n.º 1
0
        private void UpdateAppStatuses()
        {
            while (Get() != null)
            {
                if (Visible)
                {
                    if (Core.UpdateAvailable)
                    {
                        BuildDate.Invoke((MethodInvoker) delegate { BuildDate.Text = Core.Version + " (Update available, click here!)"; });
                    }

                    foreach (var entry in m_AppRowDictionary)
                    {
                        App             app      = entry.Key;
                        DataGridViewRow row      = entry.Value.row;
                        AppRowTemplate  template = entry.Value.template;

                        // We wrap this in a try just because it's not exactly thread safe to the app's processes.
                        // If an exception is thrown here we can pretty safely assume the process ended one way or another - we'll just use what was cached.
                        try { app.RefreshStatuses(ref template); } catch (Exception) { }

                        row.Cells[1].Value = template.Title;
                        row.Cells[2].Value = template.Crashes;
                        row.Cells[3].Value = template.Uptime;
                        row.Cells[4].Value = template.CPU;
                        row.Cells[5].Value = template.Memory;
                    }
                }

                Thread.Sleep(750);
            }
        }
Ejemplo n.º 2
0
        private void UpdateAppStatuses()
        {
            while (Get() != null)
            {
                if (Visible)
                {
                    if (Core.UpdateAvailable)
                    {
                        BuildDate.Invoke((MethodInvoker) delegate { BuildDate.Text = Core.Version + " (Update available, click here!)"; });
                    }

                    System.Management.ManagementObjectCollection wmiRes = null;

                    try
                    {
                        System.Management.ManagementObjectSearcher wmiSearcher =
                            new System.Management.ManagementObjectSearcher("root\\CIMV2",
                                                                           "SELECT * FROM Win32_PerfFormattedData_PerfProc_Process");
                        wmiRes = wmiSearcher.Get();
                    } catch (Exception e)
                    {
                        Debug.Error("Couldn't query WMI: " + e.Message);
                    }

                    foreach (var entry in m_AppRowDictionary)
                    {
                        App             app      = entry.Key;
                        DataGridViewRow row      = entry.Value.row;
                        AppRowTemplate  template = entry.Value.template;

                        // We wrap this in a try just because it's not exactly thread safe to the app's processes.
                        // If an exception is thrown here we can pretty safely assume the process ended one way or another - we'll just use what was cached.
                        try { app.RefreshStatuses(ref template, wmiRes); } catch (Exception) { }

                        row.Cells[1].Value = template.Title;
                        row.Cells[2].Value = template.Crashes;
                        row.Cells[3].Value = template.Uptime;
                        row.Cells[4].Value = template.CPU;
                        row.Cells[5].Value = template.Memory;
                    }
                }

                Thread.Sleep(750);
            }
        }