Trending
Anambra Intensifies Hepatitis Fight Through Awareness Campaign is trending now Enugu Govt. Partners NEPWHAN To Improve Health Outcomes For People Living With HIV is trending now Sloan Sky Survey Unveils Data Release 20 is trending now Sending repurposed Mars rover to the moon could cost more than $1 billion is trending now Not just Neanderthals: Ghost lineage in Africa left its mark on our DNA is trending now Coral Reefs Presumed Dead Have Been Found Teeming With Life is trending now ‘We’ll Make Things Right,’ Super Falcons Confident Ahead Of Nigeria Vs Zambia Game is trending now Curtis Jones furious after Dominik Szoboszlai action: team-mates have to step in is trending now Real Madrid takes a stand with Vinicius is trending now 'He’ll have the bailiffs at his door!' - Cole Palmer jokes new Chelsea co-star Morgan Rog… is trending now How I almost jumped balcony, Davido opens up on suicidal thoughts - Tribune Online is trending now Davido releases sixth album ‘ORIADÉ’, featuring Mayorkun, FOLA, others is trending now Anambra Intensifies Hepatitis Fight Through Awareness Campaign is trending now Enugu Govt. Partners NEPWHAN To Improve Health Outcomes For People Living With HIV is trending now Sloan Sky Survey Unveils Data Release 20 is trending now Sending repurposed Mars rover to the moon could cost more than $1 billion is trending now Not just Neanderthals: Ghost lineage in Africa left its mark on our DNA is trending now Coral Reefs Presumed Dead Have Been Found Teeming With Life is trending now ‘We’ll Make Things Right,’ Super Falcons Confident Ahead Of Nigeria Vs Zambia Game is trending now Curtis Jones furious after Dominik Szoboszlai action: team-mates have to step in is trending now Real Madrid takes a stand with Vinicius is trending now 'He’ll have the bailiffs at his door!' - Cole Palmer jokes new Chelsea co-star Morgan Rog… is trending now How I almost jumped balcony, Davido opens up on suicidal thoughts - Tribune Online is trending now Davido releases sixth album ‘ORIADÉ’, featuring Mayorkun, FOLA, others 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