示例代码
using System;
using System.Threading;
using System.Windows.Forms;
namespace ClickDemo
{
public partial class Form1 : Form
{
private string text = "";
public Form1()
{
InitializeComponent();
}
private void button_Click(object sender, EventArgs e)
{
print(1,true);
setEnable(false);
print(2);
Thread.Sleep(2000);
print(3);
setEnable(true);
print(4);
}
private void setEnable(bool enable)
{
this.button.Enabled = enable;
}
private void print(int num,bool isPrint = false)
{
if (isPrint)
{
text += "\r\n---------------------------------";
}
text += $"\r\n{DateTime.Now} button state{num}: {this.button.Enabled}";
this.textBox.Text = text;
}
private void