I'd like to explain today what do put in the two virtual methods as I saw many people getting confused about which one to use. I'll also talk about the creation flow of a tasklet
The OnStarted virtual method can be compared to a class constructor as it is called only once per instance. The OnActivated is called after starting the Tasklet or when navigating back to it.
First the framework creates the instance of the Tasklet and then it sets all its "framework properties": Definition, Container, MainMenuManager, ContextMenuManager.
Then it injects all services (properties with the RolePadService attribute) in your Tasklet, set the OrchestrationInfo, the Configuration, add the Actions properties.
Finally it will inject the input parameters (properties with InputParameter attribute), start the Tasklet (call OnStarted) and activate the Tasklet (call OnActivated).
So what should you put in the OnStarted and what should you put in OnActivated?
In the OnStarted, you should do all the tasks that need to be done once. Like creating the custom menu items (the ones that don't come from the UserRole), populate the view (that is setting the orchestration name, the wizard step number by calling PopulateView... but not filling the view with data) and show the view. But you should also initialize some variables, like for a tasklet that will use the barcode reader, you should create the barcodeReader instance using the BarcodeScanningService in there. Why? Because you only need to create this class once and you cannot do it in the constructor of your class because you need to the BarcodeScanningService which is a RolePadService and is injected after the constructor has been called. So doing it in OnStarted is the right place.
In the OnActivated, you should put the code that should be executed when this Tasklet is becoming the "active" one... For example, when you navigate from Tasklet A to Tasklet B and close Tasklet B, the OnActivated will be called on Tasklet A.
So, let's say that my Tasklet is filling a list based on an sql query. Every time that my Tasklet is becoming the active Tasklet, I will have to refresh my list as another Tasklet might have modified the data in the database.
For a tasklet using the barcode reader, it will need to open the barcode reader in OnActivated and disable it in OnDeactivated.


