There are two threads: main and additional. Addidional thread works in infinite loop and should be stopped after the main thread ends or application ends. Could you tell me the best way to tell AdditionalThread that it should be stopped? Maybe i should use some event, which is automatically generated after "return" in main thread or maybe check somehow if main thread .IsAlive() or i should use AppDomain.ProcessExit?
void main()
{
Thread.CurrentThread.Name = "MainThread";
Thread addThread = new Thread(DoSomething)
addThread.Name = "AdditionalThread";
addThread.IsBackground = false;
addThread.Start();
return 0;
}
DoSomething()
{
While( true || /* while mainthread is working */)
{
/* do something */
}
}
Thank you!