A task can be encapsulated in a class if the task logic is not very simple one or two lines of code. Therefore, if you want to encapsulate a task in a class, you can simply create a class inheriting a base class named CodedTaskBase. Then, override a method named "ExecuteAsync" that returns a Task<string> type. The string is just a message about the task which will be shown in the Log. Here is an example of an encapsulated task class.
Once you encapsulate a task in a separate class, you can include an instance of that class in the TaskIndex class as shown here.