{"id":22888368,"url":"https://github.com/gravity00/taskslikepromises","last_synced_at":"2025-10-07T03:39:44.991Z","repository":{"id":75304792,"uuid":"228359934","full_name":"gravity00/TasksLikePromises","owner":"gravity00","description":"Extensions for using C# Task Parallel Library (TPL) in a similar way to Javascript Promises","archived":false,"fork":false,"pushed_at":"2020-09-30T12:00:34.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-20T18:18:16.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/gravity00.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-12-16T10:20:14.000Z","updated_at":"2024-01-15T23:15:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"50503bde-93fb-4c5e-ac5d-297470485733","html_url":"https://github.com/gravity00/TasksLikePromises","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gravity00/TasksLikePromises","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity00%2FTasksLikePromises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity00%2FTasksLikePromises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity00%2FTasksLikePromises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity00%2FTasksLikePromises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gravity00","download_url":"https://codeload.github.com/gravity00/TasksLikePromises/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gravity00%2FTasksLikePromises/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278717090,"owners_count":26033535,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-13T20:47:54.659Z","updated_at":"2025-10-07T03:39:44.965Z","avatar_url":"https://github.com/gravity00.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TasksLikePromises\n\nExtensions for using C# Task Parallel Library (TPL) in a similar way to Javascript Promises (Then / Catch / Finally). This may be helpfull when developing applications that have .NET 4.0 as a requirement without using async/await keywords.\n\nIt also contains a `Promise` static class with some helpul methods:\n\nName | Type | Description |\n--- | --- | --- |\n`Canceled` | Property | Singleton `Task` in the canceled state\n`Cancel\u003cT\u003e()` | Method | Returns a `Task\u003cT\u003e` in the canceled state\n`Resolved` | Property | Singleton `Task` in the completed state\n`Resolve\u003cT\u003e(value)` | Method | Returns a `Task\u003cT\u003e` in the completed state with the given value\n`Reject\u003cT\u003e(exception)` | Method | Returns a `Task\u003cT\u003e` in the faulted state using the exception as a cause\n`Reject\u003cT\u003e(exceptions)` | Method | Returns a `Task\u003cT\u003e` in the faulted state using the exceptions as a cause\n`Reject(exception)` | Method | Returns a `Task` in the faulted state using the exception as a cause\n`Reject(exceptions)` | Method | Returns a `Task` in the faulted state using the exceptions as a cause\n`Timeout(delay)` | Method | Returns a `Task` that will complete after a given delay\n\n## Installation \nThis library can be installed via [NuGet](https://www.nuget.org/packages/TasksLikePromises/) package. Just run the following command:\n\n```powershell\nInstall-Package TasksLikePromises\n```\n\n## Compatibility\n\nThis library is compatible with the folowing frameworks:\n\n* .NET Framework 4.0\n* .NET Framework 4.5\n* .NET Standard 1.0\n* .NET Standard 2.0\n\n## Usage\n```csharp\npublic static class UsageExample\n{\n    private static readonly HttpClientHandler HttpHandler = new HttpClientHandler();\n\n    public static Task HttpAsync(CancellationToken ct)\n    {\n        return Promise\n            .Resolve(new HttpClient(HttpHandler, false))\n            .Then(client =\u003e Promise\n                .Resolve(new HttpRequestMessage(HttpMethod.Get, \"https://httpstat.us/200\"))\n                .Then(request =\u003e client\n                    .SendAsync(request, ct)\n                    .Then(response =\u003e response.Content\n                        .ReadAsStringAsync()\n                        .Then(content =\u003e\n                        {\n                            Console.WriteLine($\"StatusCode: {response.StatusCode}\");\n                            Console.WriteLine($\"Content: {content}\");\n                        })\n                        .Finally(response.Dispose))\n                    .Finally(request.Dispose))\n                .Catch(exception =\u003e\n                {\n                    Console.WriteLine(\"Unhandled exception has been thrown\");\n                    Console.WriteLine(exception);\n                })\n                .Finally(client.Dispose));\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravity00%2Ftaskslikepromises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgravity00%2Ftaskslikepromises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgravity00%2Ftaskslikepromises/lists"}