Created
January 15, 2020 13:50
-
-
Save juucustodio/ef6b60821c0595dee5c071d00b3f9fcb to your computer and use it in GitHub Desktop.
Example of how to use Background Services in Xamarin.Forms applications. - http://julianocustodio.com/background-services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DemoBackground.Services; | |
using Matcha.BackgroundService; | |
using Xamarin.Forms; | |
namespace DemoBackground | |
{ | |
public partial class App : Application | |
{ | |
public App() | |
{ | |
InitializeComponent(); | |
MainPage = new Views.MainPage(); | |
} | |
protected override void OnStart() | |
{ | |
// Registra | |
BackgroundAggregatorService.Add(() => new BackgroundService(15)); | |
// Inicia | |
BackgroundAggregatorService.StartBackgroundService(); | |
} | |
protected override void OnSleep() | |
{ | |
// Para | |
BackgroundAggregatorService.StopBackgroundService(); | |
} | |
protected override void OnResume() | |
{ | |
// Inicia Novamente | |
BackgroundAggregatorService.StartBackgroundService(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment