One thread suspension
I am starting to learn about threads and I wrote this code.
static void Main(string[] args)
{
Thread DoAction = new Thread(StartAction);
DoAction.Start();
for (int i = 0; i < 10000000; i++)
{
Console.WriteLine("Main Thread: {0}", i);
if (i == 10000) DoAction.Suspend();
}
}
static void StartAction()
{
for(int i=0;i<int.MaxValue;++i)
{
Console.WriteLine(i);
}
}
When I == 10000 my application stopped. I want to suspend only DoAction Thread
+3
source to share