{"id":13709958,"url":"https://github.com/aritchie/jobs","last_synced_at":"2025-05-06T18:33:29.113Z","repository":{"id":33204795,"uuid":"148716281","full_name":"aritchie/jobs","owner":"aritchie","description":"Background Jobs Framework for Xamarin \u0026 UWP","archived":true,"fork":false,"pushed_at":"2022-12-08T03:45:26.000Z","size":4097,"stargazers_count":82,"open_issues_count":2,"forks_count":15,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-14T23:22:44.747Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aritchie.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-14T01:01:24.000Z","updated_at":"2023-08-23T17:55:01.000Z","dependencies_parsed_at":"2022-08-27T12:11:39.520Z","dependency_job_id":null,"html_url":"https://github.com/aritchie/jobs","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aritchie%2Fjobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aritchie%2Fjobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aritchie%2Fjobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aritchie%2Fjobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aritchie","download_url":"https://codeload.github.com/aritchie/jobs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252744839,"owners_count":21797689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T23:00:49.253Z","updated_at":"2025-05-06T18:33:27.570Z","avatar_url":"https://github.com/aritchie.png","language":"C#","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# UPDATE - This library has has moved to the Shiny Framework at https://github.com/shinyorg/shiny \n\n# ACR Background Jobs Plugin for Xamarin \u0026 Windows\n\n[Change Log - March 5, 2019](changelog.md)\n### [SUPPORT THIS PROJECT](https://allancritchie.net/projects)\n\nPlugin.Jobs|[![NuGet](https://img.shields.io/nuget/v/Plugin.Jobs.svg?maxAge=2592000)](https://www.nuget.org/packages/Plugin.Jobs/)\n\n### BUILDS\nBranch|Status\n------|------\nMaster|[![Build status](https://dev.azure.com/allanritchie/Plugins/_apis/build/status/Jobs?branchName=master)](https://dev.azure.com/allanritchie/Plugins/_build/latest?definitionId=0)\nDev|[![Build status](https://dev.azure.com/allanritchie/Plugins/_apis/build/status/Jobs?branchName=dev)](https://dev.azure.com/allanritchie/Plugins/_build/latest?definitionId=0)\n\n\n\n## PLATFORMS\n\nPlatform|Version\n--------|-------\nAndroid|5.0+\niOS|8+\nWindows UWP|16299+\nAny Other Platform|Must Support .NET Standard 2.0\n\niOS, Android, \u0026 UWP implementations use [Xamarin Essentials](https://github.com/xamarin/essentials)\n\n## FEATURES\n* Cross Platform Background Jobs Framework\n* Run adhoc jobs in the background (mainly for use on iOS)\n* Define jobs with runtime parameters to run at regular intervals\n* Internal logging to let you know how often jobs are running, if they complete successfully or error\n* Place criteria as to when jobs can run responsibly\n    * device is charging \n    * battery is not low\n    * Internet connectivity via Mobile\n    * Internet connectivity via WiFi\n\n## DOCS\n* Setup\n    * [Android](platform_android.md)\n    * [iOS](platform_ios.md)\n    * [UWP](platform_uwp.md)\n* [Running Adhoc One-Time Tasks](#adhoc)\n* [Scheduling Background Jobs](#schedule)\n* [Cancelling Jobs](#cancel)\n* [Running Jobs On-Demand](#ondemand)\n* [Querying Jobs, Run Logs, \u0026 Events](other.md)\n* [Dependency Injection](di.md)\n* [FAQ - Frequently Asked Questions](faq.md)\n    \n## SETUP\n\nInstall From [![NuGet](https://img.shields.io/nuget/v/Plugin.Jobs.svg?maxAge=2592000)](https://www.nuget.org/packages/Plugin.Jobs/)\n\nFollow the Setup Guids\n* [Android](platform_android.md)\n* [iOS](platform_ios.md)\n* [UWP](platform_uwp.md)\n\n## HOW TO USE\n\n\n#### \u003ca name=\"adhoc\"\u003e\u003c/a\u003eCreating a One-Time Adhoc Job\n```csharp\n\n// To issue an adhoc task that can continue to run in the background \nCrossJobs.Current.RunTask(async () =\u003e \n{\n    // your code\n});\n```\n\n#### \u003ca name=\"schedule\"\u003e\u003c/a\u003eScheduling a background job\n```csharp\n// first define your job\npublic class YourJob : IJob\n{\n    public async Task Run(JobInfo jobInfo, CancellationToken cancelToken)\n    {\n        var loops = jobInfo.GetValue(\"LoopCount\", 25);\n\n        for (var i = 0; i \u003c loops; i++)\n        {\n            if (cancelToken.IsCancellationRequested)\n                break;\n\n            await Task.Delay(1000, cancelToken).ConfigureAwait(false);\n        }\n    }\n}\nvar job = new JobInfo\n{\n    Name = \"YourJobName\",\n    Type = typeof(YourJob),\n\n    // these are criteria that must be met in order for your job to run\n    BatteryNotLow = this.BatteryNotLow,\n    DeviceCharging = this.DeviceCharging\n    NetworkType = NetworkType.Any,\n    Repeat = true; //defaults to true, set to false to run once OR set it inside a job to cancel further execution\n};\n\n// you can pass variables to your job\njob.SetValue(\"LoopCount\", 10);\n\n\n// lastly, schedule it to go - don't worry about scheduling something more than once, we just update if your job name matches an existing one\nCrossJobs.Current.Schedule(job);\n```\n\n#### \u003ca name=\"cancel\"\u003e\u003c/a\u003eCancelling Jobs\n```csharp\n// Cancelling A Job\nCrossJobs.Current.Cancel(\"YourJobName\");\n\n// Cancelling All Jobs\nCrossJobs.Current.CancelAll();\n```\n\n#### \u003ca name=\"ondemand\"\u003e\u003c/a\u003eRunning Jobs On-Demand\n```csharp\n// Run All Jobs On-Demand\nvar results = await CrossJobs.Current.RunAll();\n\n// Run A Specific Job On-Demand\nvar result = await CrossJobs.Current.Run(\"YourJobName\");\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faritchie%2Fjobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faritchie%2Fjobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faritchie%2Fjobs/lists"}