In this specific case, it sounds like you just need a post-processing hook.
In its simplest form, it could look like this:
class BaseClass
{
protected virtual void PostProcess()
{
//No code, do nothing
}
public void Run()
{
//Do Task 1
//Do Task 2
PostProcess();
}
}
class A : BaseClass
{
protected override void PostProcess()
{
//Do task 3
}
}
class B : BaseClass
{
protected override void PostProcess()
{
//Do task 4
}
}
Another common pattern looks like this:
class BaseClass
{
public virtual void Run()
{
//Do Task 1
//Do Task 2
}
}
class A : BaseClass
{
public override void Run()
{
base.Run();
//Do task 3
}
}
class B : BaseClass
{
public override void Run()
{
base.Run();
//Do task 4
}
}
These show the basics of two common approaches. Depending on your requirements, you might want to make the base class abstract, or you might want to use an event instead of a method for the post-processing hook, or you might wish to extract Task1 and Task2 to separate methods, etc.
You could also solve this problem without inheritance, e.g. you could have a single class and define the post-processing behavior by injecting it, or via composition instead of inheritance.