码迷,mamicode.com
首页 > 编程语言 > 详细

C# 线程中操作空间

时间:2015-01-03 17:09:06      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

1.在Form1类中添加以下代码

 private delegate void UpdateStatusDelegate(string status);
        private void UpdateStatus(string status)
        {
            this.textBox1.Text = status;
        }

2.

 private void OnBtUsbRead(object sender, EventArgs e)
        {
            Thread t = new Thread(new ThreadStart(Go));
            t.Start();   // Run Go() on the new thread.
            Go();        // Simultaneously run Go() in the main thread.
         }
        private  void Go()
        {
            this.BeginInvoke(new UpdateStatusDelegate(UpdateStatus), new object[] { "123"});
        }

 

C# 线程中操作空间

标签:

原文地址:http://www.cnblogs.com/yuqilihualuo/p/4199679.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!