You can do this by storing the code in an abstract class that executes the "before" and "after" code when you call Run() :
public abstract class Job { protected virtual void Before() {
And in the calling code:
new CustomJob().Run();
Of course, for each piece of custom code you will need to create a new class, which may be less desirable.
An easier way is to use Action :
public class BeforeAndAfterRunner { protected virtual void Before() {
What can you name like this:
public void OneOfYourMethods() {
source share