刚学习线程编了个程序,但是程序总是假死,求指导~
功能是:界面上就一个Button,按下Button2秒后就会在当前激活的窗口中按下F5
程序代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace Key
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Thread thr = new Thread(key);
thr.IsBackground = true;
thr.Start();
} private void key()
{
thread.sleep(2000);
System.Windows.Forms.SendKeys.Send("{F5}");
}
}
}
功能是:界面上就一个Button,按下Button2秒后就会在当前激活的窗口中按下F5
程序代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace Key
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Thread thr = new Thread(key);
thr.IsBackground = true;
thr.Start();
} private void key()
{
thread.sleep(2000);
System.Windows.Forms.SendKeys.Send("{F5}");
}
}
}
解决方案 »
- C#中使用MySqlDriverCS参数预处时如何查询
- 从数据库中读文件并显示在网页上
- 关于C#引用
- C# ArrayList与结构体
- 关于Enterprise Library4 logging 中的FlatFileTraceListenerData的文件存储问题
- 新手--如何用webBrowser填写表单
- 关于从数据库中读出数据,然后保存到Excel模板中(asp.net(C#))
- 请问有没有C#开发的VOD点播系统的源码啊?
- 再问最后一次~~~~~~~~~~
- 迷茫的程序人生,程序员以后的方向
- 大神们,帮我看看图片在数据库存储读取问题。
- DatagridView 怎样按下Enter 或 UP 或 Down 到 下一行
private void key()
{
Thread.Sleep(2000);
System.Windows.Forms.SendKeys.SendWait("1313");
}
{
thread.sleep(2000);
F5();
}
}
void F5()
{
if (InvokeRequired)
{
BeginInvoke(new Action(F5));
}
else
{
System.Windows.Forms.SendKeys.Send("{F5}");}
}