A software engineers guide to the galaxy

Sep 19, 2008

strange c# lambda expression behavior

Here's a nice one:

public static void Foreach<T>(
this IEnumerable<T> collection,
Action<T> action)
{
foreach (var item in collection)
action(item);
}

public static IEnumerable<T> Foreach<T>(
this IEnumerable collection,
Func<Object, T> action)
{
foreach (var item in collection)
yield return action(item);
}

var files = Directory.GetFiles(dir, "*.xml");
// #1
files.Foreach(xmlFile => DoSomething(xmlFile));

// #2
files.Foreach(xmlFile => { DoSomething(xmlFile); });

Given that the files array is not empty.

#1 doesn't call DoSomething(), #2 does. Why?

Labels: ,

Sep 14, 2008

What a week!?!

Gee first of my monday was crappy (like all my mondays).
Tuesday i had a breakin in my car, they stole my gps, my ipod and my jacket??.. What a great start of the week!
11:45 it was announced that my boss Niels was fired (Linked in), which totally blows, cuz he was a really great boss!
When i got home i had an email from my server with kernel dump attached. I havent had a kernel dump since last time my server was breached! And guess what some noob tard script kiddie had tried to hack my server!
Anyways it took most of my evening to verify that he didnt succed, pheewww

The rest of the week was spend installing mediatomb on my server for my ps3. It mostly works, i can play mp3 and divx movies. but for some reason mkv movies and jpg images doesnt work :(
And im yet to figure out how to "transcode" iso images of dvd's with vlc.

Labels: , , , ,

Aug 28, 2008

Memory leaks in .NET

I'm currently working on creating an ESB solution (like Biz Talk). In the process a memory leak was discovered, I found this site which describes how to use Perfmon to track leaks in .Net code.

After alt of debugging we found that the MSMQ integration in .NET leaks memory when fetching public Queues :(

Labels: , ,