在前面的数独题目中,若自动解题功能想要计时,而算的时间又比较长,此时使用Windows.Form.Timer进行刷新会卡住不刷新。
当时是使用多开一个线程来解决这个问题的,其实可以使用Threading中的Timer来解决,如:
public Sudoku()
{
// 500ms执行一次
Timer timer = new Timer( new TimerCallback( TimerFunction ), null, 0, 500 );
}
//刷新label显示时间的方法
void TimerFunction(object obj)
{
Console.WriteLine(m_nRand.ToString());
}