私は C# と .NET プログラミングが初めてで、Windows TaskManager のような Windows フォーム アプリケーションを開発しようとしています。最初に、System.Diagnostics.Process から収集した情報を使用して listView にデータを入力します。次に、リストビュー データを毎秒更新しようとする MethodInvoker デリゲートを使用して System.Threading.Timer を開始します。
問題は、アプリケーションが非常に遅いことです。そして、確かに、私は愚かなことをしています。
public partial class Form1 : Form
    {
        private System.Threading.Timer t;
        private Process[] procVett;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            this.loadAppInfo(null);
            TimerCallback timerDelegate = new TimerCallback(this.refresh);
            this.t = new System.Threading.Timer(timerDelegate, null, 1000, 3000);
        }
        private void refresh(Object stateInfo)
        {
            procVett = Process.GetProcesses();
            this.BeginInvoke( (MethodInvoker)delegate
            {
                ListView.ListViewItemCollection ic = this.appList.Items;
                ListView.ListViewItemCollection procIc = this.procList.Items;
                time.Text = DateTime.Now.ToLongTimeString();
                int count = 0;
                procList.BeginUpdate();
                foreach (Process p in procVett)
                {
                    try
                    {
                        string cputime = p.TotalProcessorTime.TotalMinutes.ToString();
                        procIc[count].SubItems[1].Text = ("");
                        procIc[count].SubItems[2].Text = (cputime);
                        procIc[count].SubItems[3].Text =(p.WorkingSet64.ToString());
                        procIc[count].SubItems[4].Text = ("");
                    }
                    catch (System.Exception)
                    {
                    }
                    count++;
                }
                procList.EndUpdate();
            }, null);
        }
}