不用线程也可以阿..
让他更新
listView1.Items.clear();
重新添加
让他更新
listView1.Items.clear();
重新添加
解决方案 »
- 语音控件 SAPI如何输入不同比特率采样率的wav文件 C#
- 调用存储过程问题,代码如下
- 怎样在一幅大的PNG图片中获得其中一小部分的确切位置?
- 谁能教教我如何调用shdocvw.dll,新手,真正的新手,请感觉一下你们十岁时学这个的心情。。。。
- vs对窗体大小的限制问题
- 在vs2005下使用Nant和Nantcontrib做自动构建,出现问题?急
- ViewState的问题, 还是看不太明白他到底是做什么用的。 谢谢
- 用c#写的BHO怎么样不让资源管理器调用啊
- 今天Broland来我们公司查盗版软件了,散糞
- 复制 DropDownList 之后,莫名其妙的“同步选择”,奇怪的问题。
- 书中的例子怎么调试不了——关于多线程的,简单的很!
- c#中用鼠标移动控件的问题。
using System;
using System.Threading;namespace AutoResetEvent_Examples
{
class MyMainClass
{
//Initially not signaled.
const int numIterations = 100;
static AutoResetEvent myResetEvent = new AutoResetEvent(false);
static int number;
static void Main()
{
//Create and start the reader thread.
Thread myReaderThread = new Thread(new ThreadStart(MyReadThreadProc));
myReaderThread.Name = "ReaderThread";
myReaderThread.Start(); for(int i = 1; i <= numIterations; i++)
{
Console.WriteLine("Writer thread writing value: {0}", i);
number = i;
//Signal that a value has been written.
myResetEvent.Set();
//Give the Reader thread an opportunity to act.
Thread.Sleep(0);
} //Terminate the reader thread.
myReaderThread.Abort();
} static void MyReadThreadProc()
{
while(true)
{
//The value will not be read until the writer has written
// at least once since the last read.
myResetEvent.WaitOne();
Console.WriteLine("{0} reading value: {1}", Thread.CurrentThread.Name, number);
}
}
}
}