{"id":19101587,"url":"https://github.com/thomaslevesque/AspNetCore.AsyncInitialization","last_synced_at":"2025-04-18T18:32:45.171Z","repository":{"id":60773880,"uuid":"150008188","full_name":"thomaslevesque/AspNetCore.AsyncInitialization","owner":"thomaslevesque","description":"Async initialization in ASP.NET Core 2.x","archived":false,"fork":false,"pushed_at":"2022-09-01T17:29:39.000Z","size":42,"stargazers_count":87,"open_issues_count":1,"forks_count":9,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-31T22:50:22.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomaslevesque.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-23T17:27:22.000Z","updated_at":"2024-04-16T13:03:05.000Z","dependencies_parsed_at":"2022-10-04T15:31:02.807Z","dependency_job_id":null,"html_url":"https://github.com/thomaslevesque/AspNetCore.AsyncInitialization","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FAspNetCore.AsyncInitialization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FAspNetCore.AsyncInitialization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FAspNetCore.AsyncInitialization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FAspNetCore.AsyncInitialization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomaslevesque","download_url":"https://codeload.github.com/thomaslevesque/AspNetCore.AsyncInitialization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223602673,"owners_count":17171952,"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-11-09T03:53:21.881Z","updated_at":"2024-11-09T03:57:54.049Z","avatar_url":"https://github.com/thomaslevesque.png","language":"C#","funding_links":[],"categories":["others","C\\#"],"sub_categories":[],"readme":"# AspNetCore.AsyncInitialization\n\n[![NuGet version](https://img.shields.io/nuget/v/AspNetCore.AsyncInitialization.svg?logo=nuget)](https://www.nuget.org/packages/AspNetCore.AsyncInitialization)\n[![AppVeyor build](https://img.shields.io/appveyor/ci/thomaslevesque/aspnetcore-asyncinitialization.svg?logo=appveyor)](https://ci.appveyor.com/project/thomaslevesque/aspnetcore-asyncinitialization)\n[![AppVeyor tests](https://img.shields.io/appveyor/tests/thomaslevesque/aspnetcore-asyncinitialization.svg?logo=appveyor)](https://ci.appveyor.com/project/thomaslevesque/aspnetcore-asyncinitialization/build/tests)\n\nA simple helper to perform async application initialization in ASP.NET Core 2.x.\n\n***Note:** This project supports **only** ASP.NET Core 2.x. If you need to perform async initialization for the generic host (.NET Core 2.1+ and ASP.NET Core 3), use [Extensions.Hosting.AsyncInitialization](https://github.com/thomaslevesque/Extensions.Hosting.AsyncInitialization) instead.*\n\n## Usage\n\n1. Install the [AspNetCore.AsyncInitialization](https://www.nuget.org/packages/AspNetCore.AsyncInitialization/) NuGet package:\n\n    Command line:\n\n    ```PowerShell\n    dotnet add package AspNetCore.AsyncInitialization\n    ```\n\n    Package manager console:\n    ```PowerShell\n    Install-Package AspNetCore.AsyncInitialization\n    ```\n\n\n1. Create a class (or several) that implements `IAsyncInitializer`. This class can depend on any registered service.\n\n    ```csharp\n    public class MyAppInitializer : IAsyncInitializer\n    {\n        public MyAppInitializer(IFoo foo, IBar bar)\n        {\n            ...\n        }\n\n        public async Task InitializeAsync()\n        {\n            // Initialization code here\n        }\n    }\n    ```\n\n1. Register your initializer(s) in the `Startup.ConfigureServices` method:\n\n    ```csharp\n        services.AddAsyncInitializer\u003cMyAppInitializer\u003e();\n    ```\n\n1. In the `Program` class, make the `Main` method async and change its code to initialize the host before running it:\n\n    ```csharp\n    public static async Task Main(string[] args)\n    {\n        var host = CreateWebHostBuilder(args).Build();\n        await host.InitAsync();\n        host.Run();\n    }\n    ```\n\n(Note that you need to [set the C# language version to 7.1 or higher in your project](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version#edit-the-csproj-file) to enable the \"async Main\" feature.)\n\nThis will run each initializer, in the order in which they were registered.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2FAspNetCore.AsyncInitialization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomaslevesque%2FAspNetCore.AsyncInitialization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2FAspNetCore.AsyncInitialization/lists"}