I have an abstract class MyAbstractDoerClass which has an abstract method called DoItAsync as follow:
public class MyAbtractDoerClass
{
public abstract Task DoItAsync();
}
It also has a couple of derived classes PainterClass and EraserClass:
public class PainterClass : MyAbtractDoerClass
{
public override async Task DoItAsync();
}
public class EraserClass : MyAbtractDoerClass
{
public override async Task DoItAsync();
}
Finally, there is a Factory method that returns an instance of any of these two classes. The signature is something like this:
public MyAbstractClass Factory(string doerType)
Now, my code looks like this:
var doer = Factory("painter");
await doer.DoItAsync(); // <--- here is the problem.
Given that MyAbstractClass.DoItAsync method is an abstract one, it cannot be marked as async and because of that I cannot use the await keyword in the API client. That makes my API usability seem very bad. I suspect there is something wrong in my design, some concept that I didn't fully understand but I don't know what.
What is wrong with my code?
Update
This is the error that I got in VS:
And this is the method's signature in the abstract class: