我使用两个threading.timer来控制两股车流的添加,车流采用的是自定义控件,每股车流10个控件,还有一个threading.timer来控制界面内控件的移动,当有控件移动到屏幕外后使用dispose()释放内存,界面随着控件数的减少不是应该越来越流畅吗,但是反而越来越卡顿,界面的关闭最小化等按钮都无法点击。
不知道是什么原因,求大家帮帮我
public void timer_Tick(object sender)
{
foreach (Control c in this.pictureBox1.Controls)
{
Application.DoEvents();
if (c is CarControl && ((CarControl)c).Beginloc == CarControl.Carloct.Column)
{
if (c.Location.Y <= 160)
{
((CarControl)c).Sport = 测试1.CarControl.CarState.Right;
this.pictureBox1.Refresh();
X_cut_Render(c);
}
else
Y_cut_Render(c);
}
else if (c is CarControl && ((CarControl)c).Beginloc == CarControl.Carloct.Row )
{
if (c.Location.X <= 450)
{
((CarControl)c).Sport = 测试1.CarControl.CarState.Right;
this.pictureBox1.Refresh();
Y_cut_Render(c);
}
else
X_cut_Render(c);
}
else continue;
}
ClearMemory();
}
这是控制控件移动的代码