protected override async void OnHandleIntent(Intent intent) { int interval = intent.GetIntExtra("interval", 10); bool wifiOnly = intent.GetBooleanExtra("autoUpload", true); SyncService sync = App.Container.Resolve <SyncService>(); await sync.AutoUpload(TimeSpan.FromMinutes(interval), wifiOnly); }
public async Task Start() { _taskId = UIApplication.SharedApplication.BeginBackgroundTask("LongRunningTask", OnExpiration); await Task.Run(async() => { SyncService syncService = App.Container.Resolve <SyncService>(); int interval = _configuration.Api.SyncInterval; await syncService.AutoUpload(TimeSpan.FromMinutes(interval), Settings.Current.WifiOnly); }); UIApplication.SharedApplication.EndBackgroundTask(_taskId); }