public System.Timers.Timer trime; //定时器
public int count=0; //定时器变量,累加计数时用到
public void A(string a)
{
//主窗体中会调用A方法,给出a的值。
trime = new System.Timers.Timer(1000);
trime.AutoReset = true;//执行一次false,一直执行true;
trime.Enabled = true;//是否执行Elapsed事件
trime.Elapsed += new System.Timers.ElapsedEventHandler(TimerUp);
}
public void TimerUp(object sender, ElapsedEventArgs e)
{
count++;
try
{
foreach (System.Windows.Forms.Control control in mapPictureBox.Controls)
{
//////问: 怎么传递参数,用来代替判断条件中的“1”
if (control.Text.Equals("1")) //控件名称如果为a,则a闪烁
{
this.Invoke((MethodInvoker)delegate
{
if (count % 2 == 0)
{
control.BackColor = System.Drawing.Color.Red;
}
else
{
control.BackColor = System.Drawing.Color.Yellow;
}
});
}
}
HasAlert = true;
}
catch { }
}
请各位大神指点