如题:
点击按钮,将启用一个定时器每隔100mshttp://ask.csdn.net/#将集合中的一组数据添加到dgv中。但刷新的速度越来越慢,也就意味着有部分定时器事件压根就没有执行。是什么原因导致越来越慢的呢
这是定时器事件:
private void timer1_Tick(object sender, EventArgs e)
{
Thread ord1=new Thread(()=>
{
this.Invoke(new Action<string>(c =>
{
int inde = dgv1.Rows.Add();
//添加新行并返回行的索引
DataGridViewRow row = dgv1.Rows[inde];
student stur = select.selectRdn();//从集合里随机取一组数据,这组数据将放到row对象里。
tbName.Text = stur.name;
tbAge.Text = stur.age.ToString();
tbScore.Text = stur.score.ToString();
row.Cells["姓名"].Value = tbName.Text.Trim();
row.Cells["年龄"].Value = tbAge.Text.Trim();
row.Cells["成绩"].Value = tbScore.Text.Trim();
row.Cells["Datetime"].Value = System.DateTime.Now;
row.Cells["编号"].Value = row.Index + 1;
dgv1.ClearSelection();//取消选定所有的单元格
dgv1.CurrentCell = dgv1.Rows[inde].Cells[0];
dgv1.Rows[inde].Selected = true;
dgv1.FirstDisplayedScrollingRowIndex = row.Index;
//tbName.Text = string.Empty;
////tbAge.Text = string.Empty;
////tbScore.Text = string.Empty;
}), "1");
} );
ord1.IsBackground = true;
ord1.Start();
}
怎么解决变慢的问题呢