Example #1
0
        public static void readdata()
        {
            readproc procinfo = new readproc();
            Process[] proclist = new Process[200];
            proclist = procinfo.getprocesses();

            for (int i = 0; i < proclist.Length; i++)
            {
                try
                {
                    System.Windows.Forms.ListViewItem listviewitem = new System.Windows.Forms.ListViewItem(new string[] {
                     proclist[i].ProcessName,
                     procinfo.GetProcessUserName(proclist[i].Id),
                     procinfo.GetCpuPerformance(proclist[i].ProcessName),
                     proclist[i].MainModule.ModuleMemorySize.ToString(),
                     proclist[i].MainModule.FileName,
                     Convert.ToString(proclist[i].Id)}, -1);
                    form.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[]{listviewitem});

                }
                catch
                {
                    continue;
                }
            }
        }
Example #2
0
        private static void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            readproc procinfo = new readproc();
               Process[] proclist = new Process[200];
               proclist = procinfo.getprocesses();

               //System.Windows.Forms.ListViewItem[] listviewitem1 = null;

               //form.listView1.BeginUpdate();
               form.listView1.Items.Clear();
               for (int i = 0; i < proclist.Length; i++)
               {
               try
               {
                   System.Windows.Forms.ListViewItem listviewitem = new System.Windows.Forms.ListViewItem(new string[] {
                     proclist[i].ProcessName,
                     procinfo.GetProcessUserName(proclist[i].Id),
                     procinfo.GetCpuPerformance(proclist[i].ProcessName),
                     proclist[i].MainModule.ModuleMemorySize.ToString(),
                     proclist[i].MainModule.FileName}, -1);

                   /*listviewitem1[i] = new System.Windows.Forms.ListViewItem(new string[] {
                     proclist[i].ProcessName,
                     procinfo.GetProcessUserName(proclist[i].Id),
                     procinfo.GetCpuPerformance(proclist[i].ProcessName),
                     proclist[i].MainModule.ModuleMemorySize.ToString(),
                     proclist[i].MainModule.FileName}, -1);
                   */
                   form.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[]{listviewitem});

               }
               catch
               {
                   continue;
               }
               }
               //form.listView1.Items.AddRange(listviewitem1);
               //form.listView1.EndUpdate();
        }