public void setItemAndShow(object threadName)
{
lock (mylock)
{
int intItem = (int)myItem;
if (intItem < 200)
{
if (threadName != null)
{
string stringThread = threadName.ToString();
intItem++;
myItem = (object)intItem;
Invoke(new MethodInvoker(delegate ()
{
listBox1.Items.Add(myItem.ToString() + " , " + stringThread);
}));
}
}
else
{
MessageBox.Show(threadName + " finish!");
Thread.CurrentThread.Abort();
}
}
//Thread.Sleep(0);
setItemAndShow(threadName);
}
{
lock (mylock)
{
int intItem = (int)myItem;
if (intItem < 200)
{
if (threadName != null)
{
string stringThread = threadName.ToString();
intItem++;
myItem = (object)intItem;
Invoke(new MethodInvoker(delegate ()
{
listBox1.Items.Add(myItem.ToString() + " , " + stringThread);
}));
}
}
else
{
MessageBox.Show(threadName + " finish!");
Thread.CurrentThread.Abort();
}
}
//Thread.Sleep(0);
setItemAndShow(threadName);
}