Trending
Reducing Malaria-Related Under-Five Mortality in Nigeria Through Scalable Prevention and … is trending now NACA Seeks Sustainable Financing To Safeguard Nigeria’s HIV Response is trending now Africa: 'What Is the Plan?' - Inside South Africa's Reckoning With a Post-PEPFAR World is trending now New Molecule Cooperation Method Discovered at Room Temp is trending now Mars rover discovers honeycomb-like fields on Red Planet is trending now Female birds have shorter lifespans than male birds across 35 North American species, res… is trending now My family has vacationed in the same beach town for 30 years. It's taught me the value of… is trending now Ucheibe attributes Malawi defeat to game’s growth is trending now CWG: Enekwechi wins Nigeria’s first-ever men’s shot put gold medal is trending now Real Madrid sign Carlos Espí for €25M from Levante is trending now UEFA will boycott FIFA tournaments if Gianni Infantino continues with plans to sell off s… is trending now Peller And Jarvis Seal Union With Civil Wedding Ahead Of Saturday Ceremony is trending now Reducing Malaria-Related Under-Five Mortality in Nigeria Through Scalable Prevention and … is trending now NACA Seeks Sustainable Financing To Safeguard Nigeria’s HIV Response is trending now Africa: 'What Is the Plan?' - Inside South Africa's Reckoning With a Post-PEPFAR World is trending now New Molecule Cooperation Method Discovered at Room Temp is trending now Mars rover discovers honeycomb-like fields on Red Planet is trending now Female birds have shorter lifespans than male birds across 35 North American species, res… is trending now My family has vacationed in the same beach town for 30 years. It's taught me the value of… is trending now Ucheibe attributes Malawi defeat to game’s growth is trending now CWG: Enekwechi wins Nigeria’s first-ever men’s shot put gold medal is trending now Real Madrid sign Carlos Espí for €25M from Levante is trending now UEFA will boycott FIFA tournaments if Gianni Infantino continues with plans to sell off s… is trending now Peller And Jarvis Seal Union With Civil Wedding Ahead Of Saturday Ceremony is trending now
XML

Building a Task Sequence in Xamarin Forms/ MAUI (Part 2)

Building a Task Sequence in Xamarin Forms/ MAUI (Part 2)

In the first part of this series, we covered how to build a task sequence. In this part I’m going to show you how to… Continue ReadingBuilding a Task Sequence in Xamarin Forms/ MAUI (Part 2) The post Building a Task Sequence in Xamarin Forms/ MAUI (Part 2) appeared first on Xamboy.

In the first part of this series, we covered how to build a task sequence. In this part I’m going to show you how to start the sequence from a specific task, run tasks conditionally and pass parameters between tasks.

Starting from an specific task

There are scenarios where we want the task sequence to start from a task. For example, you want to start in the HomePage and skip all the previous tasks.

To achieve it, create an overload for StartAsync method of the StartupTaskSequencer class that will take an IStartupTask as parameter. This task will be the starting task in the sequence, so all the tasks previous to this one will be skipped.

In the SplashPage, when calling the StartAsync method specify which task we want to start from.

Result:

Run tasks conditionally

Is very common to run tasks only if it meets certain conditions. For example, if you have an application that shows an advertisement task only if the user is using the free version otherwise this task should be skipped.

To represent this scenario, let’s add a property for the version type in the App class.

In the AdvertisingPage by overriding the CanRunAsync method, evaluate if VersionType is free. If so task should run, otherwise will be skipped.

Passing parameters

In certain use cases we might need the output of the previous task to be the input of the next task to run. For example, you want to pass the username from the LoginPage task to the HomePage task.

To achieve it, let’s create a class to represent parameters:

Modify the IStartupTask to support parameters:

Modify StartupTaskSequencer class to pass parameters of previous task to the next running task

Pass the parameters in the CompleteAsync method of the previous task:

Evaluate and consume the parameters in the next task.

Result:

Stay tuned for the next part of this series where you’ll see how to build a task sequence using Prism.

Check the full source code here.

Happy Task Sequence!

The post Building a Task Sequence in Xamarin Forms/ MAUI (Part 2) appeared first on Xamboy.

View original source →

Related