I would like to know what happens to threads which are running in background after the object gets collected by GC? Do they kill themselves or do they turn zombie process?
private Thread currentDateTimer;
private DateTime ActualDateTime;
if (this.currentDateTimer == null)
{
this.currentDateTimer = new Thread(() =>
{
while (true)
{
this.ActualDateTime = DateTime.Now;
Thread.Sleep(60 * 1000 - (DateTime.Now.Second * 1000 + DateTime.Now.Millisecond));
}
}) { IsBackground = true };
this.currentDateTimer.Start();
}
The thread doesnt know when to stop.
Will this thread get killed once the object instance gets collected? Will GC collect this object ever since its the thread needs this.ActualDateTime?
I hope somebody had the same problem.