Created
January 15, 2020 13:49
-
-
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
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 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