我现在要做的是让我的程序在后台添加每次发生后的 5 秒,这样一旦发生 25 秒,就会触发一个事件。
有什么建议么?
这是正在发生的事情的一些代码
private void autoshapingPanel_Paint(object sender, PaintEventArgs e)
{
}
//Code for Peck Counter
private int counter = 0;
public event EventHandler Clicked5TimesEvent;
private void OnClicked5TimesEvent()
{
if (Clicked5TimesEvent != null)
{
Clicked5TimesEvent(this, EventArgs.Empty);
}
}
//Stimulus with Peck Counter
private void pictureBox1_Click(object sender, EventArgs e)
{
counter++;
if (counter % 5 == 0)
{
//Code for Hopper
//Code to Write Data
string file_name = "C:\\Users\\Carter Daniels\\DATA\\AUTOSHAPINGdata.txt";
System.IO.StreamWriter objWriter;
objWriter = new System.IO.StreamWriter(file_name, true);
objWriter.WriteLine("5 pecks");
objWriter.WriteLine("1 Reinforcement");
objWriter.Close();
//ITI Panel
ITIpanel.Visible = true;
}
}
private void ITIpanel_Paint(object sender, PaintEventArgs e)
{
if (ITIpanel.Visible == true)
{
ITItimers.Enabled = true;
}
}
private void ITItimers_Tick(object sender, EventArgs e)
{
ITIpanel.Visible = false;
string file_name = "C:\\Users\\Carter Daniels\\DATA\\AUTOSHAPINGdata.txt";
System.IO.StreamWriter objWriter;
objWriter = new System.IO.StreamWriter(file_name, true);
objWriter.WriteLine("5s ITI");
objWriter.Close();
ITItimers.Enabled = false;
autoshapingPanel.Visible = true;
}
}
}
我希望我的程序做的是计算 ITIpanel 或 ITItimers 发生的次数,并在一个或另一个之后触发一个新事件,最好计时器已经发生 20 次