日期:2014-05-17 浏览次数:20792 次
private void btnStart_Click(object sender, EventArgs e)
{
for (int na = 0; na < 2000; na++)
{
//WaitCallback wcb = new WaitCallback(ThreadPoolText);
//ThreadPool.QueueUserWorkItem(wcb, "n" + na.ToString() + "|" + na.ToString());
Thread th = new Thread(ThreadPoolText);
th.Start("n" + na.ToString() + "|" + na.ToString());
}
}
Dictionary<string, int> dic = new Dictionary<string, int>();
private void ThreadPoolText(object state)
{
string StrText = state.ToString().Split('|')[0];
int nValue = Convert.ToInt32(state.ToString().Split('|')[1]);
bool blThread = true;
dic.Add(StrText,nValue );
while (blThread)
{
Thread.Sleep(100000);
dic[StrText] = dic[StrText] + 1;
if (StrText == "")
{
blThread = false;
}
}
}