110,561
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.Text = "1";
Thread thr = new Thread(new ThreadStart(Run));
thr.IsBackground = true;
thr.Start();
}
private void Run()
{
Thread.Sleep(200);//休息200毫秒
this.textBox1.Invoke(new MethodInvoker(() => { this.textBox1.Text = "0"; }));
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function showtime() {
document.getElementById("textbox1").value="1";
setTimeout("showtime1()",500); //500是500毫秒
}
function showtime1() {
document.getElementById("textbox1").value="0";
}
</script>
</head>
<body>
<input type="text" id="textbox1" size="23" >
<input name="" type="button" value=" 保 存 " onclick="showtime()"/>
</body>
</html>