I was writing a component at work that has many events that all need to be thread safe, and was getting annoyed at the amount of duplicate code I was writing:
Hmm. There has to be a better way of doing this. Enter some Generic magic in the form of a Generic Delegate Sub:
This then allows me to write my Event Raisers like so:
Further optimisation let me do the fiollowing, as the sender is always
Which meant I no longer needed my customer Action Delegate, as there is one for a single parameter in System for this already!
Now if only I could find a way to wrap the thread safe checks and invokes into a single generic function...