{"id":13429558,"url":"https://github.com/StephenCleary/AsyncEx","last_synced_at":"2025-03-16T03:31:50.615Z","repository":{"id":16797033,"uuid":"19555723","full_name":"StephenCleary/AsyncEx","owner":"StephenCleary","description":"A helper library for async/await.","archived":false,"fork":false,"pushed_at":"2024-01-01T05:30:30.000Z","size":1217,"stargazers_count":3510,"open_issues_count":63,"forks_count":358,"subscribers_count":157,"default_branch":"master","last_synced_at":"2024-10-29T15:47:27.633Z","etag":null,"topics":["async","async-await","asyncex","await","c-sharp","task"],"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/StephenCleary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"github":["StephenCleary"]}},"created_at":"2014-05-08T00:54:59.000Z","updated_at":"2024-10-28T16:01:04.000Z","dependencies_parsed_at":"2024-01-02T22:02:32.370Z","dependency_job_id":null,"html_url":"https://github.com/StephenCleary/AsyncEx","commit_stats":{"total_commits":161,"total_committers":11,"mean_commits":"14.636363636363637","dds":0.6459627329192547,"last_synced_commit":"0361015459938f2eb8f3c1ad1021d19ee01c93a4"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenCleary%2FAsyncEx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenCleary%2FAsyncEx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenCleary%2FAsyncEx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenCleary%2FAsyncEx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephenCleary","download_url":"https://codeload.github.com/StephenCleary/AsyncEx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515526,"owners_count":20303258,"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","async-await","asyncex","await","c-sharp","task"],"created_at":"2024-07-31T02:00:41.666Z","updated_at":"2025-03-16T03:31:50.582Z","avatar_url":"https://github.com/StephenCleary.png","language":"C#","funding_links":["https://github.com/sponsors/StephenCleary"],"categories":["Frameworks, Libraries and Tools","C#","others","C# #","Async","C\\#","框架, 库和工具"],"sub_categories":["Application Frameworks","应用程序框架"],"readme":"![Logo](AsyncEx.128.png)\n\n# AsyncEx\n\nA helper library for async/await.\n\nNote: This README is for AsyncEx v5 (the current version). For AsyncEx v4, see [here](https://github.com/StephenCleary/AsyncEx/tree/v4).\n\nSupports `netstandard1.3` (including .NET 4.6, .NET Core 1.0, Xamarin.iOS 10, Xamarin.Android 7, Mono 4.6, and Universal Windows 10).\n\n[![NuGet Pre Release](https://img.shields.io/nuget/vpre/Nito.AsyncEx.svg)](https://www.nuget.org/packages/Nito.AsyncEx/) [![netstandard 1.3](https://img.shields.io/badge/netstandard-1.3-brightgreen.svg)](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) [![netstandard 2.0](https://img.shields.io/badge/netstandard-2.0-brightgreen.svg)](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) [![Code Coverage](https://coveralls.io/repos/github/StephenCleary/AsyncEx/badge.svg?branch=master)](https://coveralls.io/github/StephenCleary/AsyncEx?branch=master) [![Build status](https://ci.appveyor.com/api/projects/status/37edy7t2g377rojs/branch/master?svg=true)](https://ci.appveyor.com/project/StephenCleary/asyncex/branch/master)\n\n[![API docs](https://img.shields.io/badge/reference%20docs-api-blue.svg)](http://dotnetapis.com/pkg/Nito.AsyncEx)\n\n[Overview](doc/Home.md) - [Upgrade Guide](doc/upgrade.md)\n\n## Getting Started\n\nInstall the [NuGet package](http://www.nuget.org/packages/Nito.AsyncEx).\n\n## AsyncLock\n\nA lot of developers start using this library for `AsyncLock`, an async-compatible mutual exclusion mechanism. Using `AsyncLock` is straightforward:\n\n```C#\nprivate readonly AsyncLock _mutex = new AsyncLock();\npublic async Task UseLockAsync()\n{\n  // AsyncLock can be locked asynchronously\n  using (await _mutex.LockAsync())\n  {\n    // It's safe to await while the lock is held\n    await Task.Delay(TimeSpan.FromSeconds(1));\n  }\n}\n```\n\n`AsyncLock` also fully supports cancellation:\n\n```C#\npublic async Task UseLockAsync()\n{\n  // Attempt to take the lock only for 2 seconds.\n  var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2));\n  \n  // If the lock isn't available after 2 seconds, this will\n  //  raise OperationCanceledException.\n  using (await _mutex.LockAsync(cts.Token))\n  {\n    await Task.Delay(TimeSpan.FromSeconds(1));\n  }\n}\n```\n\n`AsyncLock` also has a synchronous API. This permits some threads to acquire the lock asynchronously while other threads acquire the lock synchronously (blocking the thread).\n\n```C#\npublic async Task UseLockAsync()\n{\n  using (await _mutex.LockAsync())\n  {\n    await Task.Delay(TimeSpan.FromSeconds(1));\n  }\n}\n\npublic void UseLock()\n{\n  using (_mutex.Lock())\n  {\n    Thread.Sleep(TimeSpan.FromSeconds(1));\n  }\n}\n```\n\n## Other Coordination Primitives\n\n`AsyncLock` is just the beginning. The AsyncEx library contains a full suite of coordination primitives: `AsyncManualResetEvent`, `AsyncAutoResetEvent`, `AsyncConditionVariable`, `AsyncMonitor`, `AsyncSemaphore`, `AsyncCountdownEvent`, and `AsyncReaderWriterLock`.\n\n## More Stuff\n\nThere's quite a few other helpful types; see [the docs for full details](doc)\n\n## Infrequently Asked Questions\n\n### Older Platforms\n\n[AsyncEx v4](https://github.com/StephenCleary/AsyncEx/tree/v4) supported .NET 4.0, Windows Store 8.1, Windows Phone Silverlight 8.0, Windows Phone Applications 8.1, and Silverlight 5.0. Support for these platforms has been dropped with AsyncEx v5.\n\nAsyncEx v3 supported Windows Store 8.0, Windows Phone Silverlight 7.5, and Silverlight 4.0. Support for these platforms has been dropped with AsyncEx v4.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStephenCleary%2FAsyncEx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FStephenCleary%2FAsyncEx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FStephenCleary%2FAsyncEx/lists"}