日期:2014-05-20  浏览次数:20679 次

c#线程问题 高手指点
我启动一个线程   要让线程具有让listBox上显示该进程的优先级别   可是老是出错   说listBox不是由线程创建的   没权限访问     高手解决下谢谢了     急!!!
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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;
using   System.Diagnostics;  

namespace   程序
{

   
        public   partial   class   ChildForm8   :   MainForm
        {
                public   ChildForm8()
                {
                        InitializeComponent();
                }

                public   void   DisplayNumbers()//线程显示数据方法
                {
                        Thread   thisthread   =   Thread.CurrentThread;
                        MessageBox.Show(thisthread.Name   +   thisthread.Priority.ToString());
                      listBox3.Items.Add(thread1.Priority);//??????????????????这里为什么不能实现??

                       
                }
               
                private   void   ChildForm8_Load(object   sender,   EventArgs   e)
                {
                       
                }

                private   void   ChildForm8_FormClosed(object   sender,   FormClosedEventArgs   e)
                {
                        BaseForm.num[7]   =   0;
                }

             
                private   void   button7_Click(object   sender,   EventArgs   e)
                {
                        ThreadStart   startDelegate   =   new   ThreadStart(DisplayNumbers);//线程关联显示数据方法委托
                        Thread   thread1   =   new   Thread(startDelegate);
                        thread1.Name   =   "我是最高优先级线程 ";
                        thread1.Priority   =   ThreadPriority.Highest;
                        thread1.Start();