Soenneker.Utils.AsyncSingleton
2.1.262
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.AsyncSingleton --version 2.1.262
NuGet\Install-Package Soenneker.Utils.AsyncSingleton -Version 2.1.262
<PackageReference Include="Soenneker.Utils.AsyncSingleton" Version="2.1.262" />
paket add Soenneker.Utils.AsyncSingleton --version 2.1.262
#r "nuget: Soenneker.Utils.AsyncSingleton, 2.1.262"
// Install Soenneker.Utils.AsyncSingleton as a Cake Addin
#addin nuget:?package=Soenneker.Utils.AsyncSingleton&version=2.1.262
// Install Soenneker.Utils.AsyncSingleton as a Cake Tool
#tool nuget:?package=Soenneker.Utils.AsyncSingleton&version=2.1.262
Soenneker.Utils.AsyncSingleton
An externally initializing singleton that uses double-check asynchronous locking, with optional async and sync disposal
Installation
dotnet add package Soenneker.Utils.AsyncSingleton
Example
The example below is a long-living HttpClient
implementation using AsyncSingleton
. It avoids the additional overhead of IHttpClientFactory
, and doesn't rely on short-lived clients.
public class HttpRequester : IDisposable, IAsyncDisposable
{
private readonly AsyncSingleton<HttpClient> _client;
public HttpRequester()
{
// This func will lazily execute once it's retrieved the first time.
// Other threads calling this at the same moment will asynchronously wait,
// and then utilize the HttpClient that was created from the first caller.
_client = new AsyncSingleton<HttpClient>(() =>
{
var socketsHandler = new SocketsHttpHandler
{
PooledConnectionLifetime = TimeSpan.FromMinutes(10),
MaxConnectionsPerServer = 10
};
return new HttpClient(socketsHandler);
});
}
public async ValueTask Get()
{
// retrieve the singleton async, thus not blocking the calling thread
await (await _client.Get()).GetAsync("https://google.com");
}
// Disposal is not necessary for AsyncSingleton unless the type used is IDisposable/IAsyncDisposable
public ValueTask DisposeAsync()
{
GC.SuppressFinalize(this);
return _client.DisposeAsync();
}
public void Dispose()
{
GC.SuppressFinalize(this);
_client.Dispose();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Nito.AsyncEx (>= 5.1.2)
- Soenneker.Extensions.ValueTask (>= 2.1.41)
NuGet packages (20)
Showing the top 5 NuGet packages that depend on Soenneker.Utils.AsyncSingleton:
Package | Downloads |
---|---|
Soenneker.Utils.MemoryStream
An easy modern MemoryStream utility |
|
Soenneker.Redis.Client
A utility library for Redis client accessibility |
|
Soenneker.Cosmos.Client
A utility library for Azure Cosmos client accessibility |
|
Soenneker.Blob.Container
A utility library for Azure Blob storage container operations |
|
Soenneker.ServiceBus.Admin
A utility library for Azure Service Bus Administration client accessibility |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.278 | 1,718 | 6/15/2024 |
2.1.277 | 390 | 6/15/2024 |
2.1.276 | 2,346 | 6/14/2024 |
2.1.275 | 6,108 | 6/1/2024 |
2.1.274 | 1,231 | 6/1/2024 |
2.1.273 | 756 | 6/1/2024 |
2.1.272 | 6,721 | 5/31/2024 |
2.1.271 | 4,207 | 5/29/2024 |
2.1.270 | 4,810 | 5/28/2024 |
2.1.269 | 2,690 | 5/27/2024 |
2.1.268 | 5,007 | 5/26/2024 |
2.1.267 | 4,928 | 5/26/2024 |
2.1.266 | 216 | 5/26/2024 |
2.1.265 | 1,798 | 5/25/2024 |
2.1.264 | 1,315 | 5/25/2024 |
2.1.263 | 1,190 | 5/25/2024 |
2.1.262 | 71 | 5/25/2024 |
2.1.261 | 969 | 5/25/2024 |
2.1.260 | 69 | 5/25/2024 |
2.1.259 | 3,494 | 5/25/2024 |
2.1.258 | 69 | 5/25/2024 |
2.1.257 | 6,326 | 5/23/2024 |
2.1.256 | 2,411 | 5/23/2024 |
2.1.255 | 1,749 | 5/22/2024 |
2.1.254 | 1,308 | 5/22/2024 |
2.1.253 | 533 | 5/22/2024 |
2.1.252 | 67 | 5/22/2024 |
2.1.251 | 67 | 5/22/2024 |
2.1.250 | 2,578 | 5/22/2024 |
2.1.249 | 6,600 | 5/18/2024 |
2.1.248 | 1,381 | 5/17/2024 |
2.1.247 | 2,324 | 5/17/2024 |
2.1.246 | 3,703 | 5/16/2024 |
2.1.245 | 923 | 5/15/2024 |
2.1.244 | 2,640 | 5/15/2024 |
2.1.243 | 5,353 | 5/12/2024 |
2.1.242 | 2,774 | 5/3/2024 |
2.1.241 | 3,344 | 4/29/2024 |
2.1.240 | 1,967 | 4/29/2024 |
2.1.239 | 3,748 | 4/28/2024 |
2.1.238 | 608 | 4/28/2024 |
2.1.237 | 699 | 4/28/2024 |
2.1.236 | 2,812 | 4/28/2024 |
2.1.235 | 386 | 4/28/2024 |
2.1.234 | 3,710 | 4/28/2024 |
2.1.233 | 799 | 4/28/2024 |
2.1.232 | 3,541 | 4/27/2024 |
2.1.231 | 71 | 4/27/2024 |
2.1.230 | 7,129 | 4/19/2024 |
2.1.229 | 4,387 | 4/18/2024 |
2.1.228 | 4,608 | 4/12/2024 |
2.1.227 | 725 | 4/12/2024 |
2.1.226 | 1,153 | 4/12/2024 |
2.1.225 | 973 | 4/12/2024 |
2.1.224 | 667 | 4/12/2024 |
2.1.223 | 969 | 4/12/2024 |
2.1.222 | 371 | 4/12/2024 |
2.1.221 | 78 | 4/12/2024 |
2.1.220 | 2,566 | 4/10/2024 |
2.1.219 | 9,861 | 4/10/2024 |
2.1.218 | 472 | 4/10/2024 |
2.1.217 | 5,440 | 4/2/2024 |
2.1.216 | 889 | 4/1/2024 |
2.1.215 | 5,188 | 3/29/2024 |
2.1.214 | 3,739 | 3/25/2024 |
2.1.213 | 436 | 3/25/2024 |
2.1.212 | 5,302 | 3/20/2024 |
2.1.211 | 3,642 | 3/19/2024 |
2.1.210 | 2,196 | 3/19/2024 |
2.1.209 | 2,388 | 3/18/2024 |
2.1.208 | 5,380 | 3/15/2024 |
2.1.207 | 3,673 | 3/13/2024 |
2.1.206 | 1,389 | 3/13/2024 |
2.1.205 | 1,823 | 3/13/2024 |
2.1.204 | 127 | 3/13/2024 |
2.1.203 | 109 | 3/13/2024 |
2.1.202 | 1,172 | 3/13/2024 |
2.1.201 | 116 | 3/13/2024 |
2.1.200 | 2,677 | 3/12/2024 |
2.1.199 | 3,386 | 3/12/2024 |
2.1.198 | 4,343 | 3/11/2024 |
2.1.197 | 3,032 | 3/11/2024 |
2.1.196 | 3,246 | 3/10/2024 |
2.1.195 | 4,292 | 3/8/2024 |
2.1.194 | 396 | 3/8/2024 |
2.1.193 | 3,073 | 3/8/2024 |
2.1.192 | 3,925 | 3/6/2024 |
2.1.191 | 3,969 | 3/4/2024 |
2.1.190 | 2,166 | 3/4/2024 |
2.1.189 | 4,583 | 3/2/2024 |
2.1.188 | 1,132 | 3/2/2024 |
2.1.187 | 1,399 | 3/2/2024 |
2.1.186 | 832 | 3/2/2024 |
2.1.185 | 546 | 3/2/2024 |
2.1.184 | 2,931 | 2/29/2024 |
2.1.183 | 982 | 2/29/2024 |
2.1.182 | 1,498 | 2/29/2024 |
2.1.181 | 2,900 | 2/26/2024 |
2.1.180 | 11,720 | 2/25/2024 |
2.1.179 | 1,391 | 2/25/2024 |
2.1.178 | 4,634 | 2/23/2024 |
2.1.177 | 4,457 | 2/22/2024 |
2.1.176 | 1,210 | 2/22/2024 |
2.1.175 | 1,423 | 2/21/2024 |
2.1.174 | 2,412 | 2/21/2024 |
2.1.173 | 2,159 | 2/21/2024 |
2.1.172 | 2,732 | 2/21/2024 |
2.1.171 | 1,142 | 2/21/2024 |
2.1.170 | 294 | 2/21/2024 |
2.1.169 | 2,598 | 2/21/2024 |
2.1.168 | 733 | 2/20/2024 |
2.1.167 | 165 | 2/20/2024 |
2.1.166 | 170 | 2/20/2024 |
2.1.165 | 3,331 | 2/20/2024 |
2.1.164 | 2,464 | 2/20/2024 |
2.1.163 | 2,407 | 2/20/2024 |
2.1.162 | 5,104 | 2/19/2024 |
2.1.161 | 4,072 | 2/17/2024 |
2.1.160 | 1,692 | 2/17/2024 |
2.1.159 | 1,149 | 2/16/2024 |
2.1.158 | 876 | 2/16/2024 |
2.1.157 | 1,464 | 2/16/2024 |
2.1.156 | 2,341 | 2/16/2024 |
2.1.155 | 2,624 | 2/16/2024 |
2.1.154 | 201 | 2/16/2024 |
2.1.153 | 1,292 | 2/16/2024 |
2.1.152 | 205 | 2/16/2024 |
2.1.151 | 193 | 2/16/2024 |
2.1.150 | 4,628 | 2/14/2024 |
2.1.149 | 1,962 | 2/13/2024 |
2.1.148 | 2,338 | 2/13/2024 |
2.1.147 | 2,801 | 2/13/2024 |
2.1.146 | 2,695 | 2/13/2024 |
2.1.145 | 3,729 | 2/12/2024 |
2.1.144 | 595 | 2/11/2024 |
2.1.143 | 4,094 | 2/11/2024 |
2.1.142 | 2,322 | 2/11/2024 |
2.1.141 | 4,782 | 2/10/2024 |
2.1.140 | 548 | 2/9/2024 |
2.1.139 | 4,435 | 2/9/2024 |
2.1.138 | 2,749 | 2/9/2024 |
2.1.137 | 734 | 2/8/2024 |
2.1.136 | 3,526 | 2/8/2024 |
2.1.135 | 1,421 | 2/8/2024 |
2.1.134 | 7,678 | 2/8/2024 |
2.1.133 | 264 | 2/8/2024 |
2.1.132 | 199 | 2/8/2024 |
2.1.131 | 4,035 | 2/7/2024 |
2.1.130 | 1,556 | 2/7/2024 |
2.1.129 | 2,707 | 2/7/2024 |
2.1.128 | 890 | 2/7/2024 |
2.1.127 | 807 | 2/6/2024 |
2.1.126 | 2,136 | 2/6/2024 |
2.1.125 | 237 | 2/6/2024 |
2.1.124 | 5,742 | 2/5/2024 |
2.1.123 | 3,778 | 2/4/2024 |
2.1.122 | 4,043 | 2/2/2024 |
2.1.121 | 4,889 | 1/31/2024 |
2.1.120 | 4,769 | 1/29/2024 |
2.1.119 | 2,788 | 1/29/2024 |
2.1.118 | 1,914 | 1/29/2024 |
2.1.117 | 3,153 | 1/28/2024 |
2.1.116 | 4,052 | 1/28/2024 |
2.1.115 | 2,355 | 1/28/2024 |
2.1.114 | 1,309 | 1/28/2024 |
2.1.113 | 1,942 | 1/27/2024 |
2.1.112 | 1,621 | 1/27/2024 |
2.1.111 | 4,296 | 1/27/2024 |
2.1.110 | 1,977 | 1/27/2024 |
2.1.109 | 5,216 | 1/27/2024 |
2.1.108 | 1,281 | 1/26/2024 |
2.1.107 | 1,671 | 1/26/2024 |
2.1.106 | 2,224 | 1/26/2024 |
2.1.105 | 3,966 | 1/26/2024 |
2.1.104 | 1,899 | 1/26/2024 |
2.1.103 | 994 | 1/26/2024 |
2.1.102 | 3,522 | 1/25/2024 |
2.1.101 | 2,734 | 1/25/2024 |
2.1.100 | 1,344 | 1/25/2024 |
2.1.99 | 4,703 | 1/25/2024 |
2.1.98 | 4,209 | 1/19/2024 |
2.1.97 | 4,563 | 1/15/2024 |
2.1.96 | 2,137 | 1/15/2024 |
2.1.95 | 1,597 | 1/15/2024 |
2.1.94 | 4,222 | 1/15/2024 |
2.1.93 | 4,314 | 1/15/2024 |
2.1.92 | 4,196 | 1/14/2024 |
2.1.91 | 5,156 | 1/13/2024 |
2.1.90 | 4,352 | 1/12/2024 |
2.1.89 | 4,215 | 1/11/2024 |
2.1.88 | 5,889 | 1/7/2024 |
2.1.87 | 4,625 | 1/5/2024 |
2.1.86 | 2,110 | 1/5/2024 |
2.1.85 | 2,579 | 1/5/2024 |
2.1.84 | 4,983 | 1/3/2024 |
2.1.83 | 3,039 | 1/1/2024 |
2.1.82 | 4,154 | 12/28/2023 |
2.1.81 | 1,687 | 12/28/2023 |
2.1.80 | 1,632 | 12/28/2023 |
2.1.79 | 3,750 | 12/27/2023 |
2.1.78 | 1,712 | 12/27/2023 |
2.1.77 | 259 | 12/27/2023 |
2.1.76 | 7,113 | 12/25/2023 |
2.1.75 | 3,914 | 12/25/2023 |
2.1.74 | 1,951 | 12/25/2023 |
2.1.73 | 536 | 12/25/2023 |
2.1.72 | 287 | 12/25/2023 |
2.1.71 | 5,458 | 12/24/2023 |
2.1.70 | 4,405 | 12/23/2023 |
2.1.69 | 2,285 | 12/23/2023 |
2.1.68 | 1,346 | 12/23/2023 |
2.1.67 | 3,255 | 12/23/2023 |
2.1.66 | 262 | 12/23/2023 |
2.1.65 | 6,409 | 12/19/2023 |
2.1.64 | 1,869 | 12/19/2023 |
2.1.63 | 4,443 | 12/12/2023 |
2.1.62 | 392 | 12/12/2023 |
2.1.61 | 2,237 | 12/11/2023 |
2.1.60 | 1,802 | 12/11/2023 |
2.1.59 | 1,078 | 12/11/2023 |
2.1.58 | 1,348 | 12/11/2023 |
2.1.57 | 662 | 12/10/2023 |
2.1.56 | 658 | 12/10/2023 |
2.1.55 | 1,557 | 12/10/2023 |
2.1.54 | 960 | 12/10/2023 |
2.1.53 | 6,838 | 12/10/2023 |
2.1.52 | 1,551 | 12/9/2023 |
2.1.51 | 884 | 12/9/2023 |
2.1.50 | 1,323 | 12/9/2023 |
2.1.49 | 2,094 | 12/9/2023 |
2.1.48 | 237 | 12/9/2023 |
2.1.47 | 967 | 12/9/2023 |
2.1.46 | 310 | 12/9/2023 |
2.1.45 | 2,459 | 12/9/2023 |
2.1.44 | 270 | 12/9/2023 |
2.1.43 | 3,695 | 12/9/2023 |
2.1.42 | 5,651 | 12/6/2023 |
2.1.41 | 1,042 | 12/6/2023 |
2.1.40 | 1,418 | 12/6/2023 |
2.1.39 | 3,262 | 12/5/2023 |
2.1.38 | 1,649 | 12/5/2023 |
2.1.37 | 954 | 12/5/2023 |
2.1.36 | 2,379 | 12/5/2023 |
2.1.35 | 258 | 12/5/2023 |
2.1.34 | 2,041 | 12/5/2023 |
2.1.33 | 269 | 12/5/2023 |
2.1.32 | 1,235 | 12/4/2023 |
2.1.31 | 1,348 | 12/4/2023 |
2.1.30 | 286 | 12/4/2023 |
2.1.29 | 7,254 | 12/4/2023 |
2.1.28 | 2,239 | 11/27/2023 |
2.1.27 | 1,088 | 11/26/2023 |
2.1.26 | 2,763 | 11/23/2023 |
2.1.25 | 2,348 | 11/23/2023 |
2.1.24 | 2,861 | 11/23/2023 |
2.1.23 | 271 | 11/23/2023 |
2.1.22 | 5,650 | 11/20/2023 |
2.1.21 | 2,751 | 11/20/2023 |
2.1.20 | 4,237 | 11/19/2023 |
2.1.19 | 2,446 | 11/19/2023 |
2.1.18 | 3,366 | 11/19/2023 |
2.1.17 | 910 | 11/18/2023 |
2.1.16 | 4,233 | 11/18/2023 |
2.1.15 | 1,128 | 11/18/2023 |
2.1.14 | 2,795 | 11/18/2023 |
2.1.13 | 693 | 11/18/2023 |
2.1.12 | 2,856 | 11/17/2023 |
2.1.11 | 2,389 | 11/17/2023 |
2.1.10 | 1,641 | 11/17/2023 |
2.1.9 | 322 | 11/17/2023 |
2.1.8 | 2,926 | 11/17/2023 |
2.1.7 | 1,575 | 11/17/2023 |
2.1.6 | 1,973 | 11/17/2023 |
2.1.5 | 1,179 | 11/17/2023 |
2.1.4 | 461 | 11/17/2023 |
2.1.3 | 2,566 | 11/16/2023 |
2.0.78 | 916 | 11/15/2023 |
2.0.77 | 285 | 11/15/2023 |
2.0.76 | 2,295 | 11/15/2023 |
2.0.2 | 291 | 11/16/2023 |
2.0.1 | 258 | 11/16/2023 |
1.0.75 | 3,351 | 11/13/2023 |
1.0.74 | 4,977 | 11/10/2023 |
1.0.73 | 4,023 | 11/9/2023 |
1.0.72 | 2,700 | 11/8/2023 |
1.0.71 | 4,201 | 11/7/2023 |
1.0.70 | 2,025 | 11/6/2023 |
1.0.69 | 2,571 | 11/3/2023 |
1.0.68 | 4,849 | 11/2/2023 |
1.0.67 | 2,699 | 11/1/2023 |
1.0.66 | 8,630 | 10/26/2023 |
1.0.65 | 5,488 | 10/19/2023 |
1.0.64 | 2,501 | 10/18/2023 |
1.0.63 | 2,299 | 10/17/2023 |
1.0.62 | 2,787 | 10/16/2023 |
1.0.61 | 5,427 | 10/13/2023 |
1.0.60 | 3,137 | 10/12/2023 |
1.0.59 | 9,298 | 9/18/2023 |
1.0.58 | 280 | 9/18/2023 |
1.0.57 | 6,517 | 9/14/2023 |
1.0.56 | 5,923 | 8/31/2023 |
1.0.55 | 3,179 | 8/30/2023 |
1.0.54 | 2,560 | 8/29/2023 |
1.0.53 | 2,519 | 8/28/2023 |
1.0.52 | 4,994 | 8/25/2023 |
1.0.51 | 2,697 | 8/24/2023 |
1.0.50 | 6,658 | 8/21/2023 |
1.0.49 | 2,581 | 8/18/2023 |
1.0.48 | 2,456 | 8/17/2023 |
1.0.47 | 4,924 | 8/16/2023 |
1.0.46 | 7,681 | 8/10/2023 |
1.0.45 | 2,690 | 8/9/2023 |
1.0.44 | 4,711 | 8/8/2023 |
1.0.43 | 3,819 | 8/7/2023 |
1.0.42 | 4,069 | 8/4/2023 |
1.0.41 | 7,208 | 7/13/2023 |
1.0.40 | 5,001 | 7/11/2023 |
1.0.39 | 2,875 | 7/10/2023 |
1.0.38 | 3,827 | 7/7/2023 |
1.0.37 | 332 | 7/7/2023 |
1.0.36 | 10,378 | 6/30/2023 |
1.0.35 | 5,346 | 6/28/2023 |
1.0.34 | 5,666 | 6/27/2023 |
1.0.33 | 6,476 | 6/26/2023 |
1.0.32 | 3,771 | 6/23/2023 |
1.0.31 | 7,828 | 6/21/2023 |
1.0.30 | 7,996 | 6/15/2023 |
1.0.29 | 3,092 | 6/14/2023 |
1.0.28 | 8,576 | 6/9/2023 |
1.0.27 | 3,774 | 6/8/2023 |
1.0.26 | 4,684 | 6/7/2023 |
1.0.25 | 5,335 | 6/6/2023 |
1.0.24 | 354 | 6/6/2023 |
1.0.23 | 4,302 | 6/5/2023 |
1.0.22 | 14,854 | 5/30/2023 |
1.0.21 | 18,277 | 5/29/2023 |
1.0.20 | 6,258 | 5/26/2023 |
1.0.19 | 7,301 | 5/25/2023 |
1.0.18 | 7,714 | 5/24/2023 |
1.0.17 | 5,137 | 5/24/2023 |
1.0.16 | 1,443 | 5/23/2023 |
1.0.15 | 1,557 | 5/23/2023 |
1.0.12 | 2,704 | 5/22/2023 |
1.0.11 | 17,512 | 5/16/2023 |
1.0.10 | 14,272 | 4/20/2023 |
1.0.9 | 13,646 | 4/3/2023 |
1.0.8 | 1,196 | 4/3/2023 |
1.0.7 | 2,359 | 3/23/2023 |
1.0.5 | 727 | 3/13/2023 |
1.0.4 | 485 | 3/11/2023 |
1.0.3 | 410 | 3/11/2023 |
1.0.2 | 413 | 3/11/2023 |
1.0.1 | 458 | 3/11/2023 |