I am new to C#.I learnt that normally all threads are foreground until unless you explicitly specify it as "background" thread using IsBackGround= true .
Some doubts popped in to my mind.
1) What is the advantage of keeping a thread as background thread?
2) When executing the folowing code :
static void Main(string[] args)
{
Thread worker = new Thread(SayHello);
worker.IsBackground = true;
worker.Start();
Console.WriteLine("Hello From Main");
}
static void SayHello()
{
Console.WriteLine("Hello World");
Console.ReadKey(true);
}
i need to use worker.Join() to keep the main thread to wait as the program terminates immediately. Apart from Join() could i use other techniques to keep the main thread wait ?