C#检测耗时操作

 1 private void BtnClickSaveCSV(object sender, EventArgs e)
 2 {
 3     checkBoxHideUseless.Checked = false;
 4     int nColumns = nColumnsExist;
 5     int nRows = dataGridView1.RowCount; //去掉最后的新行
 6     string szToBeStored = "", szDelLogs = "", szMoveLogs = "";
 7     Stopwatch sw = new Stopwatch();
 8     sw.Start();
 9     double millisecond=0;
10     for (int i = 0; i < nRows; i++)
11     {
12         if (dataGridView1.Rows[i].Visible == false)
13         {
14             //不保存隐藏(删除)的行
15             continue;
16         }
17       
18         ComposeOneLine(i, ref szToBeStored);
19         sw.Stop();
20         millisecond += sw.ElapsedMilliseconds;
21         sw.Start();
22         szToBeStored += '\n';
23         richTextBox1.Text += szToBeStored;
24         szToBeStored = "";
25     }
26 }

 

转载于:https://www.cnblogs.com/autumoonchina/p/3569551.html

你可能感兴趣的:(C#检测耗时操作)