using System.Threading;
namespace ConsoleApplication34
{
class Class3
{
public static AutoResetEvent _AutoSwitch = null;
private List<int> _Lst = new List<int> ();
private void init()
{
if (_AutoSwitch == null)
{
_AutoSwitch = new AutoResetEvent(false);
}
}
public void AddLst(int tmp)
{
//线程结束等待:
_Lst.Add(tmp);
_AutoSwitch.Set();
}
private void ThreadProc()
{
while (true)
{
int sleep = 30;
if (_Lst.Count <= 0)
{
//线程等待;
_AutoSwitch.WaitOne();
}
else
{
//........
}
}
}
}
}
namespace ConsoleApplication34
{
class Class3
{
public static AutoResetEvent _AutoSwitch = null;
private List<int> _Lst = new List<int> ();
private void init()
{
if (_AutoSwitch == null)
{
_AutoSwitch = new AutoResetEvent(false);
}
}
public void AddLst(int tmp)
{
//线程结束等待:
_Lst.Add(tmp);
_AutoSwitch.Set();
}
private void ThreadProc()
{
while (true)
{
int sleep = 30;
if (_Lst.Count <= 0)
{
//线程等待;
_AutoSwitch.WaitOne();
}
else
{
//........
}
}
}
}
}