Weak Delegates 2 After toying with weak delegates a bit more, I found that although my previous implementation was clean and useful, it was abhoridly slow. After a bit of thinking, I came up with a new method that creates a WeakReference within a closure, and generates the rest of...

Weak Delegates in CSharp Problem This idea has always plagued me -- how do I create weak delegates in C#? There is a problem with some of the code in my current engine where I want a short-lived entity to subscribe to a long-lived controller. When the entity loses ref,...

Foreach Loops I've mentioned before that foreach loops can be slow. This is often simply because of their nature of needing to retrieve an enumerator, which is a new instance of an object on the heap, everytime you loop through an object. I did some experimenting with this concept and...

Exception Performance We've all heard it many times: Exceptions are slow. The problem with this, is developers can read this and adopt bad practices under the assumption that their slowness eliminates their usefulness. Like anything else related to performance, it's best to understand when to use them, and when they...

Events and Expressions I ran into a scenario recently where I had a C# Action (That is, void params, and void return), and needed to get it to execute when an event was triggered. Any event. With any number of parameters. The way I solved this problem is using the...

Measuring Performance With all this talk about how performance affects your applications, I thought it might be worth taking a step back to look at how to measure performance. Considerations There are a few considerations to keep in mind when measuring performance. Some are more global, and others are specific...

When to Performance One of the common pieces of advice that I've received (or read on stackoverflow) in response to the question "how do I optimize xyz?" is: You should never optimize until you know that that particular logic or piece of code is the point of weakness. This bugs...

Welcome I won't lie, this blog was the result of a few people telling me that I needed to start writing things down, and linking to my OSS projects. I have a plethora of little projects I've done here and there, some of them useful (most of them not). Regardless,...