Category: Programming

Awaiting for that Button click

Why wait when we can await? I believe that most of C# developers know about the new language features for asynchronous programming with async and await keywords but how many of us are really exploiting them to full extent? Recently i was watching the excellent C# Language Internals course on PluralSight.com by Bart De Smet and came across very cool idea of using Await to wait for Button to be clicked – which pushed me to write this post and share it with everyone. By implementing a custom awaiter for Button (via extension methods) and hooking up to the Click handler…

Introducing the Unit Testing Context Pattern

Another pattern? Well yes. I write unit and integration tests almost every day and along the way i learned all kinds of different tricks and gotchas on how to be more productive and how to write less fragile tests. But one of the patterns that emerged i never saw in the code of other people so i decided to share it here since i find it very useful. I call it Testing Context Pattern and – unlike it’s name – its very simple. Idea is to create in your Test Fixture a private class called (you guessed it) TestContext and put…

Video of my game Marbles for Windows 8

Hi all, here is 1 minute video of my game Marbles for Windows 8. Its recorded on my desktop machine and played using a mouse, but it works also with touch based devices, and you can even play with multiple hands at the same time, which opens some interesting multiplayer possibilities… Let me know if you have some ideas how to improve the gameplay, what power-ups i could add etc…

Dot Net Gotcha #2 – Loop variables and Closures

This one is my favorite. Can you guess the output of this simple console application: One would expect to see numbers from 0 to 9 but here is the actual output of the app: OK that’s strange right? It turns out its like that by design. What you have there is a Closure over the loop variable. And closures in C# are done around variables and not around specific values of those variables – so that means that lambda expression gets to use the actual reference to the closed variable. Let me explain in little bit more detail: In first loop…