110,535
社区成员
发帖
与我相关
我的任务
分享
private void button1_MouseEnter(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void button1_MouseLeave(object sender, EventArgs e)
{
timer1.Enabled = false;
}
private void timer1_Tick(object sender, EventArgs e)
{
MessageBox.Show("在上面");
timer1.Enabled = false;
}
/// <summary>
/// 等待一段时间后执行一个任务
/// </summary>
/// <param name="fun"></param>
public static void WaitFor(int waitSeconds, Action fun)
{
Thread thread = new Thread(() =>
{
Thread.Sleep(waitSeconds * 1000);
fun();
});
thread.Start();
}
调用:
ThreadHelper.WaitFor(3, () =>
{
fmEvent.pnGreenSuccess.BackColor = SystemColors.Control;
});