Wednesday, April 02, 2008

C# quiz: 5/?

Consider a console application with the following Main:

        static void Main(string[] args) {
System.Threading.Timer t = new Timer(dummy =>
{
Console.WriteLine("In callback: " + DateTime.Now);
GC.Collect();

}, null, 0, 1000);

Console.ReadLine();
t = null;
}

What does the code do? Does it matter if it is compiled Debug or Release, if so, why?


(To give proper credit where credit is due, this example is heavily inspired by CLR via C# by Jeffrey Richter)


1 comment:

Anonymous said...

Hi, Can you provide some explanation for the behaviour on running in debug and release mode.