public void Start(ICoreJob job) { if (default(nint) == BackgroundId) { BackgroundId = UIApplication.SharedApplication.BeginBackgroundTask(() => { Console.WriteLine("Running out of time to complete you background task!"); UIApplication.SharedApplication.EndBackgroundTask(BackgroundId); }); Task.Run(async() => { if (IntervalMinutes != -1) { while (!cancellation.IsCancellationRequested) { job.PerformWork(); await Task.Delay(new TimeSpan(0, 0, IntervalMinutes, 0, 0)); } } else { job.PerformWork(); } UIApplication.SharedApplication.EndBackgroundTask(BackgroundId); BackgroundId = default(nint); }); } }
protected override void OnHandleIntent(Intent intent) { var jobType = intent.GetStringExtra("jobType"); var details = jobType.Split(','); job = (ICoreJob)Activator.CreateInstance(details[0], details[1]).Unwrap(); if (!TimerBackgroundService.IsProcessing) { TimerBackgroundService.IsProcessing = true; TimerElapsedEvent(); var timerIntent = new Intent(TimerUpdatedAction); SendOrderedBroadcast(timerIntent, null); TimerBackgroundService.IsProcessing = false; } }
public BackgroundTaskWorker(Context context, WorkerParameters workerParameters) : base(context, workerParameters) { var details = workerParameters.InputData.GetString("activatorDetails").Split(','); job = (ICoreJob)Activator.CreateInstance(details[0], details[1]).Unwrap(); }
public JobsController(ICoreJob iCore) { _iCore = iCore; }