首页 > 编程语言 > 详细

C# 线程中操作空间

时间:2015-01-03 17:07:31      阅读:186      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!