Template pattern is commonly used in the implementation of dotnet events to set up preconditions and respond to postconditions. The degenerate case is
void FireMyEvent(object sender, EventArgs e)
{
if (_myevent != null) _myEvent(sender, e);
}
in which the precondition is checked. In this case the precondition is that handlers can be invoked only when at least one has been bound. (Please don't tell me I should invoke the handlers asynchronously. I know that. I am illustrating Template pattern, not asynchronous programming technique.)
A more elaborate precondition might involve checking a property that governs the firing of events.
Template pattern is also commonly used to implement hooks, for example
public virtual void BeforeOpenFile(string filepath)
{
//stub
}
public virtual void AfterOpenFile(string filepath)
{
//stub
}
public sealed void OpenFile(string filepath)
{
BeforeOpenFile(filepath); //do user customisable pre-open bits
//do standard bits here
AfterOpenFile(filepath); //do user customisable post-open bits
}