Fundamentals

Fundamentals
My CodeMash 2011 Recap

CodeMash 2011 was great!! I really enjoyed the talks, the venue, the food, and the chance to meet up with friends. So, in an effort to remember everything, I'm recapping things on my blog. This is not exhaustive, nor is it all that polished. It's kind of a high level summary with links to resources as appropriate. Here is Part 1 of 2, which covers Wednesday and Thursday. Friday's notes are still in my nice little Moleskine notebook that they handed out at CodeMash. My Sessions Here are the sessions that I attended at CodeMash 2011. The links point to the info from...

posted @ Sunday, January 16, 2011 11:10 PM | Feedback (0)

Cancelling BackgroundWorker - Don't watch e.Cancel

Just a quick note about an issue that seems deceptively simple to introduce… If you are using the BackgroundWorker in your app and you've set it up to support cancellation, be careful how you write your code that watches for cancellation. BackgroundWorker has an event DoWork, which passes DoWorkEventArgs. This derives from CancelEventArgs, which has a property named Cancel. The unsuspecting developer (like me) might assume that e.Cancel is the property to check for detecting if the work has been cancelled. You might write something like: while(!e.Cancel) {  ...

posted @ Friday, January 07, 2011 4:32 PM | Feedback (5)

WPF & Entity Framework 4 - Tales from the Trenches

I recently presented "WPF & RF4 - Tales from the Trenches" at the Cleveland .NET SIG. This presentation reviews tips, tricks, and lessons learned from building real world apps with Windows Presentation Foundation 4.0 and Entity Framework 4.0. Whether you’re doing desktop, Silverlight, or web development, the EF T4 template tweaks, MVVM usage, Undo/Redo implementation, and Reactive programming tips reviewed in this presentation should come in handy. The Photo Tagger sample application includes implementations of these topics and issues. I'd highly recommend pulling this down and taking a look. Downloads WPF...

posted @ Wednesday, October 13, 2010 7:00 AM | Feedback (6)

MUF is Live on CodePlex! (Monitored Undo Framework)

The Monitored Undo Framework (MUF) is now available on CodePlex! First of all, I'd like to offer a a big thanks to my client, who allowed me to make this available. MUF is a library for implementing Undo / Redo. It was written in tandem with a WPF application, but should work ok in Silverlight too. The "Monitored" part of the name refers to the way it builds the undo / redo stacks. It does so by monitoring the property changes in the model (or view model, or whatever) and adding a change item into the...

posted @ Wednesday, October 06, 2010 10:58 PM | Feedback (4)

I <3 LinqKit – Dynamically build arbitrarily complex Linq Queries

In some cases, I need to be able to build a query that has a variable set of OR conditions. This is not simple with the default language constructs and extension methods. It’s simple to dynamically build an expression that includes AND parameters, because that is what the WHERE() extension method does. Not so easy for OR’ing together a bunch of conditions. Enter LinqKit. This is a great library. It provides some easy to use (but powerful) extension methods that let you “Or()” some conditions together. A common case is where you get a list of values that you need to add into...

posted @ Wednesday, April 14, 2010 11:42 AM | Feedback (0)

NativeMethods classes are special

“Whatever doesn’t kill you makes you stronger” That’s how I feel about Code Analysis. It’s painful, but in the end, it teaches me stuff that I didn’t know or hadn’t thought about. Richard Broida challenged me to see if I could rework some WIN32 P/Invoke code to get it to pass Code Analysis rules. My initial response was pretty close to whining, but I recovered from my temper tantrum and did some investigation. Luckily, I didn’t have to look too far… The info on the rule “CA1060:MovePInvokesToNativeMethodsClass” provided some useful guidance and explanation. So I created a class in my project called...

posted @ Monday, March 15, 2010 3:07 PM | Feedback (0)

Who knew overriding GetHashCode() was so much fun?

So, I have a project with Code Analysis turned on and it treats warnings as errors. In this project, I have a class that overrides Equals() so that I can use some of the nice collection based linq expression (like Except()). Well, code analysis doesn’t like it if you override Equals, but forget to override GetHashCode(). Needless to say, I have to override GetHashCode(). But how does one do this? Some searching turned up a bunch of interesting resources showing how to do this. However, there isn’t some cut and paste code that solves the problem. You have...

posted @ Friday, March 05, 2010 2:23 PM | Feedback (0)