private void UpdateProcesses(string nameFilter)
        {
            using (var ps = NtProcess.GetProcesses(ProcessAccessRights.DupHandle
                                                   | ProcessAccessRights.QueryLimitedInformation, true).ToDisposableList())
            {
                treeViewProcesses.SuspendLayout();

                try
                {
                    treeViewProcesses.Nodes.Clear();
                    IEnumerable <NtProcess> ps_list = ps.OrderBy(p => p.ProcessId);
                    if (!string.IsNullOrWhiteSpace(nameFilter))
                    {
                        nameFilter = nameFilter.ToLower();
                        ps_list    = ps_list.Where(p => p.Name.ToLower().Contains(nameFilter));
                    }

                    foreach (var p in ps_list)
                    {
                        TreeNode node = new ProcessTreeNode(p);
                        treeViewProcesses.Nodes.Add(node);
                    }
                }
                finally
                {
                    treeViewProcesses.ResumeLayout();
                }

                _last_filter = nameFilter;
            }
        }
Ejemplo n.º 2
0
 private void treeViewProcesses_BeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     try
     {
         ProcessTreeNode node = e.Node as ProcessTreeNode;
         if (node != null)
         {
             node.PopulateChildren();
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 3
0
        private void UpdateProcesses(string nameFilter)
        {
            Process[] ps = Process.GetProcesses();

            treeViewProcesses.SuspendLayout();

            try
            {
                treeViewProcesses.Nodes.Clear();

                Array.Sort(ps, new ProcessComparer());

                foreach (Process p in ps)
                {
                    if (!String.IsNullOrWhiteSpace(nameFilter))
                    {
                        if (!p.ProcessName.ToLower().Contains(nameFilter.ToLower()))
                        {
                            continue;
                        }
                    }

                    TreeNode node = new ProcessTreeNode(p);

                    treeViewProcesses.Nodes.Add(node);
                }
            }
            finally
            {
                foreach (Process p in ps)
                {
                    p.Close();
                }

                treeViewProcesses.ResumeLayout();
            }

            _last_filter = nameFilter;
        }