{"id":18882332,"url":"https://github.com/evandixon/skyeditor.utilities.asyncfor","last_synced_at":"2025-09-04T07:31:25.841Z","repository":{"id":71104583,"uuid":"182437921","full_name":"evandixon/SkyEditor.Utilities.AsyncFor","owner":"evandixon","description":"Run the body of a For or a For Each loop asynchronously.","archived":false,"fork":false,"pushed_at":"2019-04-20T23:56:48.000Z","size":21,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-30T03:45:59.144Z","etag":null,"topics":["async","asynchronous","dotnet","each","for","foreach"],"latest_commit_sha":null,"homepage":"","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/evandixon.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":"2019-04-20T17:54:59.000Z","updated_at":"2023-12-29T16:56:21.000Z","dependencies_parsed_at":"2024-05-05T08:30:52.648Z","dependency_job_id":null,"html_url":"https://github.com/evandixon/SkyEditor.Utilities.AsyncFor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evandixon%2FSkyEditor.Utilities.AsyncFor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evandixon%2FSkyEditor.Utilities.AsyncFor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evandixon%2FSkyEditor.Utilities.AsyncFor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evandixon%2FSkyEditor.Utilities.AsyncFor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evandixon","download_url":"https://codeload.github.com/evandixon/SkyEditor.Utilities.AsyncFor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231940622,"owners_count":18449185,"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":["async","asynchronous","dotnet","each","for","foreach"],"created_at":"2024-11-08T06:57:50.267Z","updated_at":"2024-12-31T03:42:49.151Z","avatar_url":"https://github.com/evandixon.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SkyEditor.Utilities.AsyncFor\nRun the body of a `for` or a `foreach` loop asynchronously.\n\nFeatures:\n\n* Asynchronous `for`-style loops, with optional custom step count\n* Asynchronous `foreach`-style loops\n* Monitor progress through events or progress report token\n* Optionally run all tasks one at a time, useful in scenarios where race conditions are present but you still want to monitor progress\n* Set maximum number of concurrent tasks\n\n## Examples\n### `for`\n\n```\n// Basic Example: print numbers 0 through 10 (inclusive)\nawait AsyncFor.For(0, 10, i =\u003e\n{\n    Console.WriteLine(i);\n});\n\n// Custom step count: print only the even numbers from 0 through 10 (inclusive)\nawait AsyncFor.For(0, 10, i =\u003e\n{\n    Console.WriteLine(i);\n}, stepCount: 2);\n```\n\n### `foreach`\n\n```\nvar sampleData = new[] { 0, 1, 2, 3 };\n\n// Basic usage: print all numbers in the array\nawait AsyncFor.ForEach(sampleData, data =\u003e {\n    Console.WriteLine(data);\n});\n\n// Extension method: available for all IEnumerable's and IEnumerable\u003cT\u003e's\nawait sampleData.RunAsyncForEach(data =\u003e {\n    Console.WriteLine(data);\n});\n```\n\n### Concurrency options\n```\n// Prevent more than 3 tasks from running concurrently\nawait AsyncFor.For(0, 10, i =\u003e\n{\n    Console.WriteLine(i);\n}, batchSize: 3);\n\n// Run tasks one at a time\nawait AsyncFor.For(0, 10, i =\u003e\n{\n    Console.WriteLine(i);\n}, runSynchronously: true);\n```\n\n### See progress\n```\nvar progressToken = new ProgressReportToken();\nprogressToken.ProgressChanged += (object sender, ProgressReportedEventArgs e) =\u003e\n{\n    Console.WriteLine($\"Progress: {e.Progress * 100} %\");\n};\nprogressToken.Completed += (object sender, EventArgs e) =\u003e\n{\n    Console.WriteLine(\"Completed!\");\n};\n\nawait AsyncFor.For(0, 10, i =\u003e\n{\n    Console.WriteLine(i);\n}, progressReportToken: progressToken);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevandixon%2Fskyeditor.utilities.asyncfor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevandixon%2Fskyeditor.utilities.asyncfor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevandixon%2Fskyeditor.utilities.asyncfor/lists"}