Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
 
 
Programming Blogs - Blog Catalog Blog Directory
 
 
 

Links

Social

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.


var sources = GetSources();

 

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.

Posted: Sep 26 2008, 03:26 PM by DigiMortal | with 5 comment(s)
Filed under: , ,

Comments

funny wallpaper » ForEach method and blonde me said:

Pingback from  funny wallpaper &raquo; ForEach method and blonde me

# September 26, 2008 8:46 AM

wisecarver said:

Nice :-)

# September 26, 2008 9:39 AM

Dew Drop - September 27, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - September 27, 2008 | Alvin Ashcraft's Morning Dew

# September 27, 2008 7:57 AM

Ramon Smits said:

I just read this article by DigiMortal about List&lt;T&gt;.ForEach and exceptions . His assumption was

# October 2, 2008 5:58 AM

DotNetBurner - Linq said:

DotNetBurner - burning hot .net content

# May 24, 2009 10:34 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)