Here is a nice little code I did recently, where the Command Pattern is used with a notification observer like pattern.

First of the Command Pattern, a simple interface for task with an execute method

Then the notification interface, with 2 methods, one when it started and one when its complete and the event delegate

Now the class that implements the interface, I used an abstract class so that I can just use a subclass to implement the simple task I wish to have

Now I can write a simple class that inherits from AbstractTask like this

Now to consume the task

This is more or less the simple form of creating a command pattern to run task that includes a notification to send back. It makes sense to have multiple task like creating users and running database scripts etc etc. This allows one to have flexible design and have an IEnumerable<AbstractTask> and run through each one with an execute method.

Hope this helps 🙂 Happy coding.