Your βthirdβ approach above (just using Action ) is simpler and more efficient. Your other delegate approaches create a separate method (an anonymous method using the delegate keyword), which then calls your original delegate (the Action parameter), which is optional.
The third option simply uses the passed Action , which is easier.
The first option is similar, although in this case you pass values ββthat are not needed ( Control ), and you must also define a user delegate (although you can use Action<Control,Action> instead). Since the control is not used, there is no reason to add this complexity.
On the side of the note, when you are reverting inside your exception handler, it would be better to just use throw; (and not throw ex; ), as this will correctly save the stack trace:
catch (Exception ex) {
If you are not going to register and just plan to revert, you can completely eliminate try / catch .
source share