S
Shapper
Hello,
I need to create a few Tasks which perform simple actions. For example:
public interface IAddTask {
int Run(int x, int y);
}
public Class AddTask : IAddTask {
public int Run(int x, int y) {
return x + y;
}
}
Each task has a Run method but the arguments can be different.
I would like all tasks to be seen as something "similar".
I mean, I would inject Tasks in other classes.
I am not sure if making all tasks implement an empty ITask is a good idea.
I am also not sure if this is the best way to create small snips of code ...
My example was simplified ... Usually tasks code are a little bit longer.
Any suggestion?
I need to create a few Tasks which perform simple actions. For example:
public interface IAddTask {
int Run(int x, int y);
}
public Class AddTask : IAddTask {
public int Run(int x, int y) {
return x + y;
}
}
Each task has a Run method but the arguments can be different.
I would like all tasks to be seen as something "similar".
I mean, I would inject Tasks in other classes.
I am not sure if making all tasks implement an empty ITask is a good idea.
I am also not sure if this is the best way to create small snips of code ...
My example was simplified ... Usually tasks code are a little bit longer.
Any suggestion?