刚学习线程编了个程序,但是程序总是假死,求指导~
功能是:界面上就一个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}");
        }
    }
}