You could also do it with a async Task.
private bool inCooldown = false;
private async void button1_Click(object sender, EventArgs e)
{
if (inCooldown)
return;
inCooldown = true;
// your button click code
await Task.Delay(6000);
inCooldown = false;
}
You could also use a new thread, but it depends on system resources.
private bool inCooldown = false;
private void button1_Click(object sender, EventArgs e)
{
if (inCooldown)
return;
inCooldown = true;
Task.Run(async () =>
{
await Task.Delay(6000);
inCooldown = false;
});
// your button click code
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…