{"id":23138337,"url":"https://github.com/encodeous/clockwork","last_synced_at":"2026-01-21T09:33:36.908Z","repository":{"id":103555139,"uuid":"324630261","full_name":"encodeous/clockwork","owner":"encodeous","description":"Clockwork - Simplified and High Precision Task Scheduling","archived":false,"fork":false,"pushed_at":"2022-03-18T01:42:31.000Z","size":477,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-04T21:52:42.545Z","etag":null,"topics":["task-scheduler"],"latest_commit_sha":null,"homepage":"https://encodeous.github.io/clockwork/","language":"C#","has_issues":true,"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/encodeous.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-26T20:29:49.000Z","updated_at":"2022-03-18T01:42:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"9ef0da17-e4de-4d2c-b9a3-d148a6aa6582","html_url":"https://github.com/encodeous/clockwork","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/encodeous/clockwork","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encodeous%2Fclockwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encodeous%2Fclockwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encodeous%2Fclockwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encodeous%2Fclockwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/encodeous","download_url":"https://codeload.github.com/encodeous/clockwork/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/encodeous%2Fclockwork/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631172,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["task-scheduler"],"created_at":"2024-12-17T13:10:40.866Z","updated_at":"2026-01-21T09:33:36.901Z","avatar_url":"https://github.com/encodeous.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clockwork - Rapid Task Scheduling\n\n[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/encodeous/clockwork/publish%20to%20nuget)](https://github.com/encodeous/clockwork) [![Nuget](https://img.shields.io/nuget/v/Encodeous.clockwork) ](https://www.nuget.org/packages/Encodeous.clockwork/)[![](https://img.shields.io/badge/View-Documentation-green)](https://encodeous.github.io/clockwork/index.html)\n\nClockwork is an easy to use Task Scheduler that reduces a lot of boilerplate code.\n\n## Usage\n\nClockwork can either be used with in-code attributes or with the Scheduler Api.\n\n### Clockwork with Attributes\n\nClockwork with Attributes requires the task function to be static.\n\nThere are two types of Clockwork attributes. \n\n- `Future` executes tasks bound by time or on repeat\n\n- `FutureScheduled` will schedule executions to the beginning of `Years, Months, Weeks, Days, Hours, Minutes, or Seconds` with an optional offset.\n\nHere is an example using Clockwork.\n\n```c#\nstatic void Main()\n{\n    // Start the Clockwork Scheduler\n    Clockwork.Wind();\n    Thread.Sleep(-1);\n}\n[Future(5000)]\npublic static void StartIn5Seconds()\n{\n    // This function will be run by the scheduler 5 seconds after the program starts\n    Console.WriteLine(\"Started 5 Seconds Later\");\n}\n[Future(2000, 5000)]\npublic static void RunEvery5Seconds()\n{\n    // This function will be run by the scheduler 2 seconds after the program starts, and will repeat every 5 seconds\n    Console.WriteLine(\"Running every 5 Seconds\");\n}\n[FutureScheduled(Schedule.ByMinute, -1)]\npublic static async Task RunOnStartOfMinute()\n{\n    // Clockwork also supports asynchronous functions, and will run all tasks in parallel\n    // This will not block other tasks, nor will it block the future executions of the current task\n    await Task.Delay(10000);\n}\n[FutureScheduled(Schedule.ByMonth, -1, \"Eastern Standard Time\")]\npublic static void RunOnStartOfMonth()\n{\n    // This function will be run by the scheduler on the start of every month in Eastern Standard Time\n    Console.WriteLine(\"Running on the start of every month\");\n}\n```\n\n### Clockwork with the Advanced Scheduling Api\n\nWith the Clockwork Scheduling Api, it is possible to create tasks that have custom triggers.\n\nCreate an instance of `ClockworkTaskTrigger` and call the `Activate()` function to trigger the task. Please note that tasks will not trigger unless it is added to a task scheduler.\n\nTo create tasks with the Api, use the builder pattern shown below:\n\n```c#\n// Start the Clockwork Scheduler\nClockwork.Wind();\n// Create a repeating task that runs every 5 seconds, with a delayed start of 2 seconds\nvar task = ClockworkTask.Create(() =\u003e\n    {\n        Console.WriteLine(\"Repeat every 5 seconds\");\n    })\n    .BuildTimedTask()\n    .Repeat(-1, TimeSpan.FromSeconds(5))\n    .Delayed(TimeSpan.FromSeconds(2))\n    .Build();\n\n// Custom Task Trigger\nvar trigger = new ClockworkTaskTrigger();\n// Delay the activation of the event until the task is triggered\nvar customTrigger = ClockworkTask.Create(() =\u003e\n    {\n        // This task will run on the middle of every second once the task is triggered and repeat indefinitely\n        Console.WriteLine($\"Triggered Task at {DateTime.Now.ToString(\"MMMM dd, yyyy hh:mm:ss.ffff tt\")}\");\n    })\n    .BuildScheduledTask(Schedule.BySecond)\n    .Repeat(-1)\n    .Delay(TimeSpan.FromMilliseconds(500))\n    .SetTrigger(trigger)\n    .Build();\n// Add the tasks to the scheduler\nClockwork.Default.AddAll(new []{task, customTrigger});\n\nConsole.WriteLine(\"Waiting for a newline to trigger\");\nConsole.ReadLine();\n// Trigger the execution of the task\ntrigger.Activate();\n\nThread.Sleep(-1);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencodeous%2Fclockwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fencodeous%2Fclockwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fencodeous%2Fclockwork/lists"}