从VS2005开始就不允许非创建此控件的线程来调用它,那么解决方法是在该控件所在窗体里加上一句话:
CheckForIllegalCrossThreadCalls = false;
private void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
//信号量
signel sgl = new signel(10);
//新建一个队列缓冲区
Queue<int> que = new Queue<int>(10);
Reader readerThread = new Reader(sgl,que,this);
Writer writerThread = new Writer(sgl,que,this);
//开启两个线程
Thread tRead = new Thread(readerThread.Process);
Thread tWrite= new Thread(writerThread.Process);
tRead.Start();
tWrite.Start();
}
posted on 2008-09-10 13:14
天书 阅读(1251)
评论(0) 编辑 收藏 引用