园代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;namespace SJ {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
} private void button1_Click(object sender, EventArgs e) {
int x, y;
for (int i = 0; i < 100; i++) {
x = 1;
y = 1;
while (x < 339) {
button1.Location = new Point(x, y);
x++;
Thread.Sleep(7);
}
while (y < 268) {
button1.Location = new Point(x, y);
y++;
Thread.Sleep(7);
}
while (x > 1) {
button1.Location = new Point(x, y);
x--;
Thread.Sleep(7);
}
while (y > 1) {
button1.Location = new Point(x, y);
y--;
Thread.Sleep(7);
}
} }
}
}程序无法关闭
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;namespace SJ {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
} private void button1_Click(object sender, EventArgs e) {
int x, y;
for (int i = 0; i < 100; i++) {
x = 1;
y = 1;
while (x < 339) {
button1.Location = new Point(x, y);
x++;
Thread.Sleep(7);
}
while (y < 268) {
button1.Location = new Point(x, y);
y++;
Thread.Sleep(7);
}
while (x > 1) {
button1.Location = new Point(x, y);
x--;
Thread.Sleep(7);
}
while (y > 1) {
button1.Location = new Point(x, y);
y--;
Thread.Sleep(7);
}
} }
}
}程序无法关闭
解决方案 »
- C# 如何在Execl中添加多个工作薄,高手救命!!!
- 这个onclick="这里该如何写"等同于贴中的语句
- 怎么样判断属性,是否为空呢?
- 看三层结构中降到实体规范层,不是很明白,哪位朋友跟我讲讲啊
- C#中向Word中动态插入多个表格并填充数据问题,急在线等
- 如何使鼠标移动到按钮上,使按钮有框框的效果
- 求如何计算一个文件已复制完百分率的算法(在线给分)
- 如何成功编译成执行文件后把光标文件隐藏掉???
- 如果写ActiveX控件,具有drag功能
- 想要源码的朋友,进来跟帖
- 小白求助,c#通过如何ajax传递参数到后台
- List<string> ls=new List<string>大量数量模糊查询效率问题!
都写了循环了,当然是得把循环执行完而且代码放在主线程中,
肯定是无法响应用户操作,类似于失控
//按钮的事件改成
Thread th = new Thread(() =>
{
//此处执行你的循环代码
for(;;)
{
//所有对按钮之类的控件的操作
Invoke(new Action(() =>{ button1.Location = new Point(x, y); }));
});
}
th.Start();
找到程序进程
kill