[英]IF statement executes when condition is false C#
So if I click the Button所以如果我点击按钮
This should make so the code would only executes after the buttons are enabled again.这应该使代码仅在再次启用按钮后才会执行。 (The buttons being disabled is just for the looks)
(被禁用的按钮只是为了外观)
Note:Variable "button_enabled" is global注意:变量“button_enabled”是全局变量
private void senha_b_Click(object sender, EventArgs e)
{
if (button_enabled == 1)
{
button_enabled = 0;
wait_label.Show();
senha_a.Enabled = false;
senha_b.Enabled = false;
senha_c.Enabled = false;
System.Threading.Thread.Sleep(2000);
wait_label.Hide();
senha_a.Enabled = true;
senha_b.Enabled = true;
senha_c.Enabled = true;
button_enabled = 1;
}
}
This should fix it这应该解决它
private async void senha_b_Click(object sender, EventArgs e)
{
if (button_enabled == 1)
{
button_enabled = 0;
wait_label.Show();
senha_a.Enabled = false;
senha_b.Enabled = false;
senha_c.Enabled = false;
await Task.Delay(2000);
wait_label.Hide();
senha_a.Enabled = true;
senha_b.Enabled = true;
senha_c.Enabled = true;
button_enabled = 1;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.