Thread Th = new Thread(() =>
{
for (int i = 0; i < 1; i++)
{
Thread.Sleep(100);
Thread T = new Thread(GetItemThrd);
T.IsBackground = true;
T.Start();
}
});
Th.IsBackground = true;
Th.Start();
private void GetItemThrd()
{
int CrtThrdID;
lock (this)
{
CrtThrdID = ThrdID;
Interlocked.Increment(ref ThrdID);
Invoke(new Action(() =>
{
AddRecordToDT(new List<string>() { CrtThrdID.ToString(), "正在g工作" }, ThrdTable);
}));
}
string CatName = "";
while (true)
{
if (CatQue.Count > 0)
{
以上为多线程循环运行某一段代码的部分代码
但是线程中有foreach循环.foreach循环会循环500次.但是工作到一半就不动了...
就是没有办法循环完
是什么原因呢 ,,改成for循环也没有用