Right, now that we've got the basics of reliability covered , we can move on to SafeHandle. If you've ever done any interop you should know all about handles. They're effectively pointers to internal OS resources. Pretty much everything you do in Windows has a handle involved somewhere. If you open a file, the OS gives you a file handle that you pass into functions that read/write etc from that file. If you have a window it's got a handle, and it's device context has a handle too. Happily enough...
I broke one of the main rules of programming the other day. I'm writing a control which will host a COM control. Now, this COM control has a very chatty interface. So I thought, why not write an ATL shim between my .NET control and this COM control that will handle the chatty aspects. and only pass up the important stuff. So, I duly went along and spent a week and a half implementing this C++ shim. Now the problem is that while I knew each Interop call would cost me cycles, and I knew that there...