Soenneker.Utils.AsyncSingleton
2.1.46
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.AsyncSingleton --version 2.1.46
NuGet\Install-Package Soenneker.Utils.AsyncSingleton -Version 2.1.46
<PackageReference Include="Soenneker.Utils.AsyncSingleton" Version="2.1.46" />
paket add Soenneker.Utils.AsyncSingleton --version 2.1.46
#r "nuget: Soenneker.Utils.AsyncSingleton, 2.1.46"
// Install Soenneker.Utils.AsyncSingleton as a Cake Addin
#addin nuget:?package=Soenneker.Utils.AsyncSingleton&version=2.1.46
// Install Soenneker.Utils.AsyncSingleton as a Cake Tool
#tool nuget:?package=Soenneker.Utils.AsyncSingleton&version=2.1.46
Soenneker.Utils.AsyncSingleton
An externally initializing singleton that uses double-check asynchronous locking, with optional async and sync disposal
Installation
Install-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.Task (>= 2.1.22)
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.243 | 0 | 5/12/2024 |
2.1.242 | 780 | 5/3/2024 |
2.1.241 | 3,335 | 4/29/2024 |
2.1.240 | 1,962 | 4/29/2024 |
2.1.239 | 3,741 | 4/28/2024 |
2.1.238 | 603 | 4/28/2024 |
2.1.237 | 694 | 4/28/2024 |
2.1.236 | 2,807 | 4/28/2024 |
2.1.235 | 381 | 4/28/2024 |
2.1.234 | 3,699 | 4/28/2024 |
2.1.233 | 794 | 4/28/2024 |
2.1.232 | 3,531 | 4/27/2024 |
2.1.231 | 66 | 4/27/2024 |
2.1.230 | 7,127 | 4/19/2024 |
2.1.229 | 4,385 | 4/18/2024 |
2.1.228 | 4,600 | 4/12/2024 |
2.1.227 | 721 | 4/12/2024 |
2.1.226 | 1,151 | 4/12/2024 |
2.1.225 | 971 | 4/12/2024 |
2.1.224 | 665 | 4/12/2024 |
2.1.223 | 967 | 4/12/2024 |
2.1.222 | 369 | 4/12/2024 |
2.1.221 | 76 | 4/12/2024 |
2.1.220 | 2,558 | 4/10/2024 |
2.1.219 | 9,837 | 4/10/2024 |
2.1.218 | 470 | 4/10/2024 |
2.1.217 | 5,438 | 4/2/2024 |
2.1.216 | 884 | 4/1/2024 |
2.1.215 | 5,185 | 3/29/2024 |
2.1.214 | 3,737 | 3/25/2024 |
2.1.213 | 434 | 3/25/2024 |
2.1.212 | 5,300 | 3/20/2024 |
2.1.211 | 3,636 | 3/19/2024 |
2.1.210 | 2,192 | 3/19/2024 |
2.1.209 | 2,386 | 3/18/2024 |
2.1.208 | 5,376 | 3/15/2024 |
2.1.207 | 3,667 | 3/13/2024 |
2.1.206 | 1,387 | 3/13/2024 |
2.1.205 | 1,821 | 3/13/2024 |
2.1.204 | 125 | 3/13/2024 |
2.1.203 | 107 | 3/13/2024 |
2.1.202 | 1,170 | 3/13/2024 |
2.1.201 | 114 | 3/13/2024 |
2.1.200 | 2,674 | 3/12/2024 |
2.1.199 | 3,384 | 3/12/2024 |
2.1.198 | 4,341 | 3/11/2024 |
2.1.197 | 3,023 | 3/11/2024 |
2.1.196 | 3,244 | 3/10/2024 |
2.1.195 | 4,290 | 3/8/2024 |
2.1.194 | 394 | 3/8/2024 |
2.1.193 | 3,071 | 3/8/2024 |
2.1.192 | 3,920 | 3/6/2024 |
2.1.191 | 3,967 | 3/4/2024 |
2.1.190 | 2,164 | 3/4/2024 |
2.1.189 | 4,581 | 3/2/2024 |
2.1.188 | 1,130 | 3/2/2024 |
2.1.187 | 1,397 | 3/2/2024 |
2.1.186 | 830 | 3/2/2024 |
2.1.185 | 544 | 3/2/2024 |
2.1.184 | 2,900 | 2/29/2024 |
2.1.183 | 980 | 2/29/2024 |
2.1.182 | 1,496 | 2/29/2024 |
2.1.181 | 2,898 | 2/26/2024 |
2.1.180 | 11,711 | 2/25/2024 |
2.1.179 | 1,386 | 2/25/2024 |
2.1.178 | 4,632 | 2/23/2024 |
2.1.177 | 4,453 | 2/22/2024 |
2.1.176 | 1,208 | 2/22/2024 |
2.1.175 | 1,417 | 2/21/2024 |
2.1.174 | 2,408 | 2/21/2024 |
2.1.173 | 2,157 | 2/21/2024 |
2.1.172 | 2,730 | 2/21/2024 |
2.1.171 | 1,140 | 2/21/2024 |
2.1.170 | 292 | 2/21/2024 |
2.1.169 | 2,596 | 2/21/2024 |
2.1.168 | 731 | 2/20/2024 |
2.1.167 | 163 | 2/20/2024 |
2.1.166 | 168 | 2/20/2024 |
2.1.165 | 3,327 | 2/20/2024 |
2.1.164 | 2,462 | 2/20/2024 |
2.1.163 | 2,402 | 2/20/2024 |
2.1.162 | 5,093 | 2/19/2024 |
2.1.161 | 4,070 | 2/17/2024 |
2.1.160 | 1,690 | 2/17/2024 |
2.1.159 | 1,147 | 2/16/2024 |
2.1.158 | 874 | 2/16/2024 |
2.1.157 | 1,462 | 2/16/2024 |
2.1.156 | 2,335 | 2/16/2024 |
2.1.155 | 2,622 | 2/16/2024 |
2.1.154 | 199 | 2/16/2024 |
2.1.153 | 1,288 | 2/16/2024 |
2.1.152 | 203 | 2/16/2024 |
2.1.151 | 191 | 2/16/2024 |
2.1.150 | 4,626 | 2/14/2024 |
2.1.149 | 1,960 | 2/13/2024 |
2.1.148 | 2,336 | 2/13/2024 |
2.1.147 | 2,799 | 2/13/2024 |
2.1.146 | 2,693 | 2/13/2024 |
2.1.145 | 3,727 | 2/12/2024 |
2.1.144 | 593 | 2/11/2024 |
2.1.143 | 4,090 | 2/11/2024 |
2.1.142 | 2,320 | 2/11/2024 |
2.1.141 | 4,780 | 2/10/2024 |
2.1.140 | 546 | 2/9/2024 |
2.1.139 | 4,430 | 2/9/2024 |
2.1.138 | 2,745 | 2/9/2024 |
2.1.137 | 732 | 2/8/2024 |
2.1.136 | 3,524 | 2/8/2024 |
2.1.135 | 1,419 | 2/8/2024 |
2.1.134 | 7,673 | 2/8/2024 |
2.1.133 | 261 | 2/8/2024 |
2.1.132 | 197 | 2/8/2024 |
2.1.131 | 4,033 | 2/7/2024 |
2.1.130 | 1,552 | 2/7/2024 |
2.1.129 | 2,702 | 2/7/2024 |
2.1.128 | 888 | 2/7/2024 |
2.1.127 | 805 | 2/6/2024 |
2.1.126 | 2,134 | 2/6/2024 |
2.1.125 | 235 | 2/6/2024 |
2.1.124 | 5,740 | 2/5/2024 |
2.1.123 | 3,776 | 2/4/2024 |
2.1.122 | 4,041 | 2/2/2024 |
2.1.121 | 4,886 | 1/31/2024 |
2.1.120 | 4,767 | 1/29/2024 |
2.1.119 | 2,786 | 1/29/2024 |
2.1.118 | 1,912 | 1/29/2024 |
2.1.117 | 3,149 | 1/28/2024 |
2.1.116 | 4,050 | 1/28/2024 |
2.1.115 | 2,353 | 1/28/2024 |
2.1.114 | 1,307 | 1/28/2024 |
2.1.113 | 1,940 | 1/27/2024 |
2.1.112 | 1,619 | 1/27/2024 |
2.1.111 | 4,294 | 1/27/2024 |
2.1.110 | 1,975 | 1/27/2024 |
2.1.109 | 5,214 | 1/27/2024 |
2.1.108 | 1,279 | 1/26/2024 |
2.1.107 | 1,669 | 1/26/2024 |
2.1.106 | 2,222 | 1/26/2024 |
2.1.105 | 3,964 | 1/26/2024 |
2.1.104 | 1,897 | 1/26/2024 |
2.1.103 | 992 | 1/26/2024 |
2.1.102 | 3,520 | 1/25/2024 |
2.1.101 | 2,732 | 1/25/2024 |
2.1.100 | 1,342 | 1/25/2024 |
2.1.99 | 4,699 | 1/25/2024 |
2.1.98 | 4,207 | 1/19/2024 |
2.1.97 | 4,561 | 1/15/2024 |
2.1.96 | 2,135 | 1/15/2024 |
2.1.95 | 1,595 | 1/15/2024 |
2.1.94 | 4,220 | 1/15/2024 |
2.1.93 | 4,312 | 1/15/2024 |
2.1.92 | 4,192 | 1/14/2024 |
2.1.91 | 5,152 | 1/13/2024 |
2.1.90 | 4,350 | 1/12/2024 |
2.1.89 | 4,213 | 1/11/2024 |
2.1.88 | 5,884 | 1/7/2024 |
2.1.87 | 4,623 | 1/5/2024 |
2.1.86 | 2,105 | 1/5/2024 |
2.1.85 | 2,576 | 1/5/2024 |
2.1.84 | 4,980 | 1/3/2024 |
2.1.83 | 3,036 | 1/1/2024 |
2.1.82 | 4,151 | 12/28/2023 |
2.1.81 | 1,683 | 12/28/2023 |
2.1.80 | 1,630 | 12/28/2023 |
2.1.79 | 3,745 | 12/27/2023 |
2.1.78 | 1,710 | 12/27/2023 |
2.1.77 | 257 | 12/27/2023 |
2.1.76 | 7,107 | 12/25/2023 |
2.1.75 | 3,913 | 12/25/2023 |
2.1.74 | 1,950 | 12/25/2023 |
2.1.73 | 535 | 12/25/2023 |
2.1.72 | 286 | 12/25/2023 |
2.1.71 | 5,457 | 12/24/2023 |
2.1.70 | 4,404 | 12/23/2023 |
2.1.69 | 2,284 | 12/23/2023 |
2.1.68 | 1,345 | 12/23/2023 |
2.1.67 | 3,252 | 12/23/2023 |
2.1.66 | 261 | 12/23/2023 |
2.1.65 | 6,408 | 12/19/2023 |
2.1.64 | 1,868 | 12/19/2023 |
2.1.63 | 4,441 | 12/12/2023 |
2.1.62 | 390 | 12/12/2023 |
2.1.61 | 2,235 | 12/11/2023 |
2.1.60 | 1,797 | 12/11/2023 |
2.1.59 | 1,076 | 12/11/2023 |
2.1.58 | 1,347 | 12/11/2023 |
2.1.57 | 661 | 12/10/2023 |
2.1.56 | 657 | 12/10/2023 |
2.1.55 | 1,556 | 12/10/2023 |
2.1.54 | 959 | 12/10/2023 |
2.1.53 | 6,834 | 12/10/2023 |
2.1.52 | 1,550 | 12/9/2023 |
2.1.51 | 883 | 12/9/2023 |
2.1.50 | 1,322 | 12/9/2023 |
2.1.49 | 2,093 | 12/9/2023 |
2.1.48 | 236 | 12/9/2023 |
2.1.47 | 966 | 12/9/2023 |
2.1.46 | 309 | 12/9/2023 |
2.1.45 | 2,458 | 12/9/2023 |
2.1.44 | 269 | 12/9/2023 |
2.1.43 | 3,694 | 12/9/2023 |
2.1.42 | 5,643 | 12/6/2023 |
2.1.41 | 1,041 | 12/6/2023 |
2.1.40 | 1,417 | 12/6/2023 |
2.1.39 | 3,261 | 12/5/2023 |
2.1.38 | 1,648 | 12/5/2023 |
2.1.37 | 953 | 12/5/2023 |
2.1.36 | 2,378 | 12/5/2023 |
2.1.35 | 257 | 12/5/2023 |
2.1.34 | 2,040 | 12/5/2023 |
2.1.33 | 268 | 12/5/2023 |
2.1.32 | 1,234 | 12/4/2023 |
2.1.31 | 1,347 | 12/4/2023 |
2.1.30 | 285 | 12/4/2023 |
2.1.29 | 7,247 | 12/4/2023 |
2.1.28 | 2,237 | 11/27/2023 |
2.1.27 | 1,087 | 11/26/2023 |
2.1.26 | 2,758 | 11/23/2023 |
2.1.25 | 2,347 | 11/23/2023 |
2.1.24 | 2,860 | 11/23/2023 |
2.1.23 | 270 | 11/23/2023 |
2.1.22 | 5,649 | 11/20/2023 |
2.1.21 | 2,750 | 11/20/2023 |
2.1.20 | 4,236 | 11/19/2023 |
2.1.19 | 2,445 | 11/19/2023 |
2.1.18 | 3,365 | 11/19/2023 |
2.1.17 | 909 | 11/18/2023 |
2.1.16 | 4,232 | 11/18/2023 |
2.1.15 | 1,127 | 11/18/2023 |
2.1.14 | 2,794 | 11/18/2023 |
2.1.13 | 692 | 11/18/2023 |
2.1.12 | 2,851 | 11/17/2023 |
2.1.11 | 2,384 | 11/17/2023 |
2.1.10 | 1,640 | 11/17/2023 |
2.1.9 | 321 | 11/17/2023 |
2.1.8 | 2,925 | 11/17/2023 |
2.1.7 | 1,574 | 11/17/2023 |
2.1.6 | 1,972 | 11/17/2023 |
2.1.5 | 1,178 | 11/17/2023 |
2.1.4 | 460 | 11/17/2023 |
2.1.3 | 2,565 | 11/16/2023 |
2.0.78 | 912 | 11/15/2023 |
2.0.77 | 284 | 11/15/2023 |
2.0.76 | 2,294 | 11/15/2023 |
2.0.2 | 290 | 11/16/2023 |
2.0.1 | 256 | 11/16/2023 |
1.0.75 | 3,349 | 11/13/2023 |
1.0.74 | 4,974 | 11/10/2023 |
1.0.73 | 4,022 | 11/9/2023 |
1.0.72 | 2,699 | 11/8/2023 |
1.0.71 | 4,200 | 11/7/2023 |
1.0.70 | 2,024 | 11/6/2023 |
1.0.69 | 2,570 | 11/3/2023 |
1.0.68 | 4,848 | 11/2/2023 |
1.0.67 | 2,698 | 11/1/2023 |
1.0.66 | 8,628 | 10/26/2023 |
1.0.65 | 5,487 | 10/19/2023 |
1.0.64 | 2,500 | 10/18/2023 |
1.0.63 | 2,298 | 10/17/2023 |
1.0.62 | 2,786 | 10/16/2023 |
1.0.61 | 5,421 | 10/13/2023 |
1.0.60 | 3,136 | 10/12/2023 |
1.0.59 | 9,296 | 9/18/2023 |
1.0.58 | 279 | 9/18/2023 |
1.0.57 | 6,516 | 9/14/2023 |
1.0.56 | 5,921 | 8/31/2023 |
1.0.55 | 3,178 | 8/30/2023 |
1.0.54 | 2,559 | 8/29/2023 |
1.0.53 | 2,518 | 8/28/2023 |
1.0.52 | 4,993 | 8/25/2023 |
1.0.51 | 2,696 | 8/24/2023 |
1.0.50 | 6,657 | 8/21/2023 |
1.0.49 | 2,580 | 8/18/2023 |
1.0.48 | 2,455 | 8/17/2023 |
1.0.47 | 4,923 | 8/16/2023 |
1.0.46 | 7,680 | 8/10/2023 |
1.0.45 | 2,689 | 8/9/2023 |
1.0.44 | 4,705 | 8/8/2023 |
1.0.43 | 3,813 | 8/7/2023 |
1.0.42 | 4,068 | 8/4/2023 |
1.0.41 | 7,206 | 7/13/2023 |
1.0.40 | 5,000 | 7/11/2023 |
1.0.39 | 2,874 | 7/10/2023 |
1.0.38 | 3,826 | 7/7/2023 |
1.0.37 | 331 | 7/7/2023 |
1.0.36 | 10,376 | 6/30/2023 |
1.0.35 | 5,345 | 6/28/2023 |
1.0.34 | 5,665 | 6/27/2023 |
1.0.33 | 6,470 | 6/26/2023 |
1.0.32 | 3,770 | 6/23/2023 |
1.0.31 | 7,827 | 6/21/2023 |
1.0.30 | 7,995 | 6/15/2023 |
1.0.29 | 3,091 | 6/14/2023 |
1.0.28 | 8,575 | 6/9/2023 |
1.0.27 | 3,773 | 6/8/2023 |
1.0.26 | 4,683 | 6/7/2023 |
1.0.25 | 5,334 | 6/6/2023 |
1.0.24 | 352 | 6/6/2023 |
1.0.23 | 4,301 | 6/5/2023 |
1.0.22 | 14,852 | 5/30/2023 |
1.0.21 | 18,274 | 5/29/2023 |
1.0.20 | 6,257 | 5/26/2023 |
1.0.19 | 7,295 | 5/25/2023 |
1.0.18 | 7,708 | 5/24/2023 |
1.0.17 | 5,136 | 5/24/2023 |
1.0.16 | 1,442 | 5/23/2023 |
1.0.15 | 1,556 | 5/23/2023 |
1.0.12 | 2,695 | 5/22/2023 |
1.0.11 | 17,511 | 5/16/2023 |
1.0.10 | 14,270 | 4/20/2023 |
1.0.9 | 13,642 | 4/3/2023 |
1.0.8 | 1,195 | 4/3/2023 |
1.0.7 | 2,350 | 3/23/2023 |
1.0.5 | 726 | 3/13/2023 |
1.0.4 | 484 | 3/11/2023 |
1.0.3 | 409 | 3/11/2023 |
1.0.2 | 412 | 3/11/2023 |
1.0.1 | 457 | 3/11/2023 |