我想看一个函数运行多长时间.所以我在表单上添加了一个计时器对象,我出来了这段代码:
private int counter = 0;
// Inside button click I have:
timer = new Timer();
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
Result result = new Result();
result = new GeneticAlgorithms().TabuSearch(parametersTabu, functia);
timer.Stop();
Run Code Online (Sandbox Code Playgroud)
和:
private void timer_Tick(object sender, EventArgs e)
{
counter++;
btnTabuSearch.Text = counter.ToString();
}
Run Code Online (Sandbox Code Playgroud)
但这并不算什么.为什么?