What does the following C# code do? Guess and then run it.
using System;using System.Threading;namespace AnonMethods{ class Program { static void Main(string[] args) { for (Int32 i = 0; i < 20; i++) { Thread t = new Thread(delegate() { Thread.Sleep(10); Console.WriteLine(i); }); t.Start(); } Thread.Sleep(5000); } }}
We were playing with this and similar code in the experts area at the Ottawa VS launch yesterday. Fun, fun.
My task ahead is to find a scenario that makes the subtleties of anonymous delegates useful. Anonymous delegates are certainly useful. It is the trick above with "i" that I'm talking about. I'll post in a couple days with more data on what is going on.
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010, Rich Lander
E-mail