ForEach method and blonde me

I want to tell you about List<T>.ForEach method and one of my famous blonde moments when I was debugging faulty code. LINQ makes it easy to query collections and that’s why I like it a lot. Today is friday and weekend is coming. Let’s relax and have some fun on me. Here’s one proof how n00b I can be 🙂

Well, there was a simple code that readed updated information from outer sources and suddenly there was faulty source that stopped updating process. The code was something like this.


try
{
    sources.ForEach(a => UpdateListCache());
}
catch (Exception ex)
{
    Log(ex.ToString());
}


Why this process stopped?

Well, it turns out that update method of source proxies had no exception handling and first exception that occured stopped the ForEach. So, if you see something similiar and think what may be the problem then check the method that is called in ForEach method to find out what’s going on there.


One thought on “ForEach method and blonde me

Leave a Reply

Your email address will not be published. Required fields are marked *