Andrew Arnott

News from my corner of the Visual Studio Connected Experience team, programming tips, and solutions to common programming issues.

So many exceptions… but only one can throw

When a method may throw for more than one reason, the thoughtful programmer might ask “which exception should be thrown?” Consider a method which performs argument validation, is cancelable, and also might throw based on the state of the object. What order should these validations occur so that the best exception is thrown? Here is… Read more

The cost of context switches

Context switches are not free. But how expensive are they? I wrote a small program to find out, and I’m sharing the program and its results here. I focused on purely context switches (no work is actually performed between context switches). So it’s not a real-world scenario, but it really brings out the hidden costs…. Read more