Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Created January 15, 2020 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juucustodio/ef6b60821c0595dee5c071d00b3f9fcb to your computer and use it in GitHub Desktop.
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
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