C#Timer Pass变量

时间:2015-12-21 20:20:22

标签: c# image variables timer

如何将cor_xy_ficheiro传递给计时器?它说cor_xy_ficheiro在比赛中不存在

https://gyazo.com/4f59951bc65a9b44bb5bd9b36a2b917c

2 个答案:

答案 0 :(得分:0)

似乎这个answer可以帮到你。简而言之:

Emgu.CV.Image cvImg = new Emgu.CV.Image<Bgr, Byte>(cor_xy);

答案 1 :(得分:0)

在全局域中的方法之外声明它。这样,button2_Clicktimer_ficheiro_Tick事件

都可以访问它
Image<Bgr, byte> cor_xy_ficheiro; //declare it outside

private void button2_Click(){ 
    //do something with cor_xy_ficheiro
}

private void timer_ficheiro_Tick(object sender, EventArgs e) { //name must match
    //do something with cor_xy_ficheiro
}

此外,还有三个重要的计时器设置:事件处理程序,间隔和启用。请检查三者是否都存在:

Timer timer_ficheiro = new Timer();    
timer_ficheiro.Tick += timer_ficheiro_Tick; //event handler
timer_ficheiro.Interval = 1000; //interval in ms
timer_ficheiro.Enabled = true; //This you already put

无论如何,另一个注意事项:对于代码,你应该把它作为代码放在你的问题中,而不是把它作为图像。