Skip to content

Instantly share code, notes, and snippets.

@juucustodio
Created January 15, 2020 13:49
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/f714ae20f14d8a3bb2aeeb52c2013d3c to your computer and use it in GitHub Desktop.
Save juucustodio/f714ae20f14d8a3bb2aeeb52c2013d3c 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 System;
using System.Threading.Tasks;
using Matcha.BackgroundService;
namespace DemoBackground.Services
{
public class BackgroundService : IPeriodicTask
{
public TimeSpan Interval { get; set; }
public BackgroundService(int seconds)
{
Interval = TimeSpan.FromSeconds(seconds);
}
public async Task<bool> StartJob()
{
Console.WriteLine(DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss"));
//Return true para continuar
return true;
//Return false para parar
//return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment