class Program
{
public static void Main(String[] args)
{
var c = new C();
var thread = new Thread(new ThreadStart(c.F));
thread.Start();
Console.WriteLine("Exiting main, but the program won't quit yet...");
}
}
class C
{
public void F()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Waiting {0}", i);
Thread.Sleep(1000);
}
Console.WriteLine("Now the program will quit...");
}
}
What's going on under the hood with a console application that leads to it waiting for the other thread to finish before exiting (pointer to docs fine)?
Note: I know this is a basic question - I just always managed waiting for threads to finish before and never considered there was some infrastructure that did it for me...