winform中,为什么运行点击button1的时候,会出现假死?

winform中,为什么运行点击button1的时候,会出现假死?不是异步执行的吗?为什么非要等执行完Thread.Sleep(5000);后才可以拖动窗口?
另外,就算我不用Thread.Sleep(5000);如果我这里读取数据库时间太长,也会出现假死,为什么呢,异步。。。。
C# code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public delegate void treeinvoke(int i);
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Console.WriteLine("AAA");
            System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(this.startupdate));
            th.IsBackground = true;
            th.Start();
            Console.WriteLine("BBB");
        }
 
        private void startupdate()
        {
            Console.WriteLine("CCC");
            this.BeginInvoke(new treeinvoke(this.UpdateTreeView), 0);
            Console.WriteLine("DDD");
 
        }
 
        private void UpdateTreeView(int j)
        {
 
            try
            {
                Console.WriteLine("EEE");
                Thread.Sleep(5000);
                Console.WriteLine("FFF");
            }
            catch (Exception ex)
            {
 
            }
 
        }

 

 

 

posted @ 2013-09-02 18:27  月夜风2013  阅读(528)  评论(0编辑  收藏  举报
合肥搬家公司 全自动包装机