why this lock test doesn't work ? it's throwing an exception bellow Console.Write that collection was modified....
static List<string> staticVar = new List<string>();
static void Main(string[] args)
{
Action<IEnumerable<int>> assyncMethod = enumerator =>
{
lock (staticVar)
foreach (int item in enumerator)
staticVar.Add(item.ToString());
};
assyncMethod.BeginInvoke(Enumerable.Range(0, 500000), null, null);
Thread.Sleep(100);
Console.Write(staticVar.Count());
foreach (string item in staticVar)
{
}
}