Soenneker.Utils.AsyncSingleton 2.1.282

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.AsyncSingleton --version 2.1.282                
NuGet\Install-Package Soenneker.Utils.AsyncSingleton -Version 2.1.282                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.AsyncSingleton" Version="2.1.282" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.AsyncSingleton --version 2.1.282                
#r "nuget: Soenneker.Utils.AsyncSingleton, 2.1.282"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Soenneker.Utils.AsyncSingleton as a Cake Addin
#addin nuget:?package=Soenneker.Utils.AsyncSingleton&version=2.1.282

// Install Soenneker.Utils.AsyncSingleton as a Cake Tool
#tool nuget:?package=Soenneker.Utils.AsyncSingleton&version=2.1.282                

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (24)

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.394 1,123 9/29/2024
2.1.393 953 9/29/2024
2.1.392 920 9/29/2024
2.1.391 2,593 9/27/2024
2.1.390 1,926 9/27/2024
2.1.389 63 9/27/2024
2.1.388 331 9/27/2024
2.1.387 667 9/27/2024
2.1.386 37 9/27/2024
2.1.385 4,090 9/26/2024
2.1.384 3,560 9/26/2024
2.1.383 1,573 9/26/2024
2.1.382 6,259 9/23/2024
2.1.381 2,544 9/23/2024
2.1.380 4,478 9/23/2024
2.1.379 4,371 9/23/2024
2.1.378 3,430 9/23/2024
2.1.377 709 9/23/2024
2.1.376 1,699 9/23/2024
2.1.375 64 9/23/2024
2.1.374 13,275 9/17/2024
2.1.373 636 9/17/2024
2.1.372 2,690 9/17/2024
2.1.371 2,692 9/17/2024
2.1.370 3,073 9/17/2024
2.1.369 4,189 9/17/2024
2.1.368 4,664 9/17/2024
2.1.367 14,612 9/16/2024
2.1.366 7,822 9/12/2024
2.1.365 3,004 9/11/2024
2.1.363 8,840 9/11/2024
2.1.362 17,054 9/10/2024
2.1.361 692 9/10/2024
2.1.360 1,010 9/10/2024
2.1.359 889 9/10/2024
2.1.358 3,632 9/9/2024
2.1.357 1,490 9/9/2024
2.1.356 6,224 9/9/2024
2.1.355 1,708 9/9/2024
2.1.354 6,945 9/9/2024
2.1.353 13,393 9/7/2024
2.1.352 9,829 9/6/2024
2.1.351 5,086 9/5/2024
2.1.350 5,099 9/5/2024
2.1.349 530 9/5/2024
2.1.348 113 9/5/2024
2.1.347 8,979 9/5/2024
2.1.346 988 9/4/2024
2.1.345 13,532 9/3/2024
2.1.344 6,068 9/3/2024
2.1.343 4,503 9/3/2024
2.1.342 8,633 8/29/2024
2.1.341 7,212 8/26/2024
2.1.340 7,619 8/21/2024
2.1.339 2,794 8/21/2024
2.1.338 1,614 8/20/2024
2.1.337 5,754 8/20/2024
2.1.336 96 8/20/2024
2.1.335 99 8/20/2024
2.1.334 9,682 8/19/2024
2.1.333 9,416 8/15/2024
2.1.332 9,421 8/13/2024
2.1.331 7,855 8/6/2024
2.1.330 4,288 8/6/2024
2.1.329 6,507 8/1/2024
2.1.328 1,333 8/1/2024
2.1.327 599 8/1/2024
2.1.326 9,404 7/25/2024
2.1.325 1,952 7/25/2024
2.1.324 1,690 7/25/2024
2.1.323 250 7/24/2024
2.1.322 699 7/24/2024
2.1.321 325 7/24/2024
2.1.320 8,833 7/20/2024
2.1.319 11,639 7/14/2024
2.1.318 4,427 7/14/2024
2.1.317 6,740 7/10/2024
2.1.316 2,920 7/10/2024
2.1.315 2,725 7/10/2024
2.1.314 1,576 7/10/2024
2.1.313 983 7/10/2024
2.1.312 305 7/10/2024
2.1.311 2,589 7/10/2024
2.1.310 1,329 7/9/2024
2.1.308 2,728 7/9/2024
2.1.307 81 7/9/2024
2.1.306 2,901 7/9/2024
2.1.305 6,753 7/9/2024
2.1.304 5,644 7/9/2024
2.1.303 2,717 7/9/2024
2.1.302 80 7/9/2024
2.1.301 2,169 7/9/2024
2.1.300 6,062 7/8/2024
2.1.299 349 7/8/2024
2.1.298 83 7/8/2024
2.1.297 90 7/8/2024
2.1.296 8,308 7/8/2024
2.1.295 1,614 7/7/2024
2.1.294 5,031 7/7/2024
2.1.293 104 7/7/2024
2.1.292 1,422 7/7/2024
2.1.291 3,060 7/7/2024
2.1.290 10,197 7/3/2024
2.1.289 3,254 7/3/2024
2.1.288 2,901 7/3/2024
2.1.287 813 7/3/2024
2.1.286 5,593 7/2/2024
2.1.283 3,506 6/30/2024
2.1.282 2,351 6/28/2024
2.1.281 224 6/28/2024
2.1.279 7,608 6/22/2024
2.1.278 8,525 6/15/2024
2.1.277 1,146 6/15/2024
2.1.276 6,688 6/14/2024
2.1.275 10,663 6/1/2024
2.1.274 1,709 6/1/2024
2.1.273 1,079 6/1/2024
2.1.272 9,344 5/31/2024
2.1.271 5,827 5/29/2024
2.1.270 6,639 5/28/2024
2.1.269 3,704 5/27/2024
2.1.268 6,882 5/26/2024
2.1.267 6,796 5/26/2024
2.1.266 294 5/26/2024
2.1.265 2,482 5/25/2024
2.1.264 1,794 5/25/2024
2.1.263 1,649 5/25/2024
2.1.262 96 5/25/2024
2.1.261 1,333 5/25/2024
2.1.260 94 5/25/2024
2.1.259 4,828 5/25/2024
2.1.258 89 5/25/2024
2.1.257 8,664 5/23/2024
2.1.256 3,425 5/23/2024
2.1.255 2,407 5/22/2024
2.1.254 1,843 5/22/2024
2.1.253 732 5/22/2024
2.1.252 88 5/22/2024
2.1.251 87 5/22/2024
2.1.250 3,579 5/22/2024
2.1.249 9,209 5/18/2024
2.1.248 1,926 5/17/2024
2.1.247 3,293 5/17/2024
2.1.246 5,161 5/16/2024
2.1.245 1,323 5/15/2024
2.1.244 3,754 5/15/2024
2.1.243 7,722 5/12/2024
2.1.242 4,180 5/3/2024
2.1.241 4,708 4/29/2024
2.1.240 2,669 4/29/2024
2.1.239 5,137 4/28/2024
2.1.238 835 4/28/2024
2.1.237 955 4/28/2024
2.1.236 3,886 4/28/2024
2.1.235 530 4/28/2024
2.1.234 5,134 4/28/2024
2.1.233 1,069 4/28/2024
2.1.232 4,847 4/27/2024
2.1.231 94 4/27/2024
2.1.230 9,736 4/19/2024
2.1.229 6,042 4/18/2024
2.1.228 6,327 4/12/2024
2.1.227 1,005 4/12/2024
2.1.226 1,607 4/12/2024
2.1.225 1,344 4/12/2024
2.1.224 943 4/12/2024
2.1.223 1,355 4/12/2024
2.1.222 508 4/12/2024
2.1.221 101 4/12/2024
2.1.220 3,555 4/10/2024
2.1.219 13,769 4/10/2024
2.1.218 661 4/10/2024
2.1.217 7,538 4/2/2024
2.1.216 1,302 4/1/2024
2.1.215 7,220 3/29/2024
2.1.214 5,253 3/25/2024
2.1.213 591 3/25/2024
2.1.212 7,296 3/20/2024
2.1.211 4,950 3/19/2024
2.1.210 2,978 3/19/2024
2.1.209 3,282 3/18/2024
2.1.208 7,278 3/15/2024
2.1.207 4,952 3/13/2024
2.1.206 1,892 3/13/2024
2.1.205 2,450 3/13/2024
2.1.204 148 3/13/2024
2.1.203 129 3/13/2024
2.1.202 1,634 3/13/2024
2.1.201 143 3/13/2024
2.1.200 3,561 3/12/2024
2.1.199 4,560 3/12/2024
2.1.198 5,955 3/11/2024
2.1.197 4,140 3/11/2024
2.1.196 4,457 3/10/2024
2.1.195 5,761 3/8/2024
2.1.194 517 3/8/2024
2.1.193 4,140 3/8/2024
2.1.192 5,357 3/6/2024
2.1.191 5,330 3/4/2024
2.1.190 3,014 3/4/2024
2.1.189 6,046 3/2/2024
2.1.188 1,541 3/2/2024
2.1.187 1,888 3/2/2024
2.1.186 1,078 3/2/2024
2.1.185 743 3/2/2024
2.1.184 3,989 2/29/2024
2.1.183 1,319 2/29/2024
2.1.182 2,038 2/29/2024
2.1.181 3,918 2/26/2024
2.1.180 15,130 2/25/2024
2.1.179 1,790 2/25/2024
2.1.178 5,960 2/23/2024
2.1.177 5,786 2/22/2024
2.1.176 1,598 2/22/2024
2.1.175 1,945 2/21/2024
2.1.174 3,146 2/21/2024
2.1.173 2,835 2/21/2024
2.1.172 3,540 2/21/2024
2.1.171 1,524 2/21/2024
2.1.170 338 2/21/2024
2.1.169 3,274 2/21/2024
2.1.168 1,003 2/20/2024
2.1.167 187 2/20/2024
2.1.166 195 2/20/2024
2.1.165 4,353 2/20/2024
2.1.164 3,269 2/20/2024
2.1.163 3,168 2/20/2024
2.1.162 6,666 2/19/2024
2.1.161 5,305 2/17/2024
2.1.160 2,198 2/17/2024
2.1.159 1,567 2/16/2024
2.1.158 1,141 2/16/2024
2.1.157 1,931 2/16/2024
2.1.156 2,971 2/16/2024
2.1.155 3,415 2/16/2024
2.1.154 225 2/16/2024
2.1.153 1,683 2/16/2024
2.1.152 227 2/16/2024
2.1.151 221 2/16/2024
2.1.150 5,883 2/14/2024
2.1.149 2,490 2/13/2024
2.1.148 3,000 2/13/2024
2.1.147 3,623 2/13/2024
2.1.146 3,476 2/13/2024
2.1.145 4,804 2/12/2024
2.1.144 749 2/11/2024
2.1.143 5,228 2/11/2024
2.1.142 2,936 2/11/2024
2.1.141 6,095 2/10/2024
2.1.140 753 2/9/2024
2.1.139 5,563 2/9/2024
2.1.138 3,597 2/9/2024
2.1.137 937 2/8/2024
2.1.136 4,491 2/8/2024
2.1.135 1,818 2/8/2024
2.1.134 10,419 2/8/2024
2.1.133 297 2/8/2024
2.1.132 227 2/8/2024
2.1.131 5,119 2/7/2024
2.1.130 2,027 2/7/2024
2.1.129 3,489 2/7/2024
2.1.128 1,134 2/7/2024
2.1.127 993 2/6/2024
2.1.126 2,775 2/6/2024
2.1.125 263 2/6/2024
2.1.124 7,376 2/5/2024
2.1.123 4,814 2/4/2024
2.1.122 5,124 2/2/2024
2.1.121 6,102 1/31/2024
2.1.120 5,993 1/29/2024
2.1.119 3,601 1/29/2024
2.1.118 2,426 1/29/2024
2.1.117 3,868 1/28/2024
2.1.116 5,131 1/28/2024
2.1.115 2,908 1/28/2024
2.1.114 1,700 1/28/2024
2.1.113 2,317 1/27/2024
2.1.112 2,038 1/27/2024
2.1.111 5,349 1/27/2024
2.1.110 2,683 1/27/2024
2.1.109 6,420 1/27/2024
2.1.108 1,660 1/26/2024
2.1.107 2,086 1/26/2024
2.1.106 2,726 1/26/2024
2.1.105 4,937 1/26/2024
2.1.104 2,341 1/26/2024
2.1.103 1,300 1/26/2024
2.1.102 4,401 1/25/2024
2.1.101 3,485 1/25/2024
2.1.100 1,695 1/25/2024
2.1.99 5,639 1/25/2024
2.1.98 5,427 1/19/2024
2.1.97 5,635 1/15/2024
2.1.96 2,574 1/15/2024
2.1.95 2,023 1/15/2024
2.1.94 5,134 1/15/2024
2.1.93 5,257 1/15/2024
2.1.92 5,091 1/14/2024
2.1.91 6,248 1/13/2024
2.1.90 5,235 1/12/2024
2.1.89 5,125 1/11/2024
2.1.88 7,099 1/7/2024
2.1.87 5,650 1/5/2024
2.1.86 2,507 1/5/2024
2.1.85 3,208 1/5/2024
2.1.84 6,028 1/3/2024
2.1.83 3,680 1/1/2024
2.1.82 5,021 12/28/2023
2.1.81 2,016 12/28/2023
2.1.80 2,045 12/28/2023
2.1.79 4,510 12/27/2023
2.1.78 2,126 12/27/2023
2.1.77 283 12/27/2023
2.1.76 8,675 12/25/2023
2.1.75 4,769 12/25/2023
2.1.74 2,419 12/25/2023
2.1.73 683 12/25/2023
2.1.72 309 12/25/2023
2.1.71 6,838 12/24/2023
2.1.70 5,342 12/23/2023
2.1.69 2,868 12/23/2023
2.1.68 1,694 12/23/2023
2.1.67 3,840 12/23/2023
2.1.66 280 12/23/2023
2.1.65 8,090 12/19/2023
2.1.64 2,227 12/19/2023
2.1.63 5,482 12/12/2023
2.1.62 454 12/12/2023
2.1.61 2,697 12/11/2023
2.1.60 2,192 12/11/2023
2.1.59 1,221 12/11/2023
2.1.58 1,643 12/11/2023
2.1.57 814 12/10/2023
2.1.56 790 12/10/2023
2.1.55 1,811 12/10/2023
2.1.54 1,115 12/10/2023
2.1.53 8,154 12/10/2023
2.1.52 1,849 12/9/2023
2.1.51 1,041 12/9/2023
2.1.50 1,597 12/9/2023
2.1.49 2,460 12/9/2023
2.1.48 255 12/9/2023
2.1.47 1,265 12/9/2023
2.1.46 329 12/9/2023
2.1.45 2,836 12/9/2023
2.1.44 288 12/9/2023
2.1.43 4,472 12/9/2023
2.1.42 6,730 12/6/2023
2.1.41 1,224 12/6/2023
2.1.40 1,752 12/6/2023
2.1.39 3,950 12/5/2023
2.1.38 1,991 12/5/2023
2.1.37 1,125 12/5/2023
2.1.36 2,851 12/5/2023
2.1.35 283 12/5/2023
2.1.34 2,425 12/5/2023
2.1.33 292 12/5/2023
2.1.32 1,601 12/4/2023
2.1.31 1,529 12/4/2023
2.1.30 319 12/4/2023
2.1.29 8,773 12/4/2023
2.1.28 2,886 11/27/2023
2.1.27 1,353 11/26/2023
2.1.26 3,388 11/23/2023
2.1.25 2,916 11/23/2023
2.1.24 3,564 11/23/2023
2.1.23 292 11/23/2023
2.1.22 6,998 11/20/2023
2.1.21 3,371 11/20/2023
2.1.20 5,458 11/19/2023
2.1.19 2,999 11/19/2023
2.1.18 4,124 11/19/2023
2.1.17 1,104 11/18/2023
2.1.16 5,329 11/18/2023
2.1.15 1,297 11/18/2023
2.1.14 3,404 11/18/2023
2.1.13 747 11/18/2023
2.1.12 3,544 11/17/2023
2.1.11 2,919 11/17/2023
2.1.10 2,166 11/17/2023
2.1.9 399 11/17/2023
2.1.8 3,447 11/17/2023
2.1.7 2,001 11/17/2023
2.1.6 2,519 11/17/2023
2.1.5 1,697 11/17/2023
2.1.4 580 11/17/2023
2.1.3 3,232 11/16/2023
2.0.78 1,119 11/15/2023
2.0.77 309 11/15/2023
2.0.76 2,908 11/15/2023
2.0.2 315 11/16/2023
2.0.1 277 11/16/2023
1.0.75 4,200 11/13/2023
1.0.74 6,073 11/10/2023
1.0.73 4,779 11/9/2023
1.0.72 3,242 11/8/2023
1.0.71 4,977 11/7/2023
1.0.70 2,463 11/6/2023
1.0.69 3,097 11/3/2023
1.0.68 5,593 11/2/2023
1.0.67 3,413 11/1/2023
1.0.66 10,845 10/26/2023
1.0.65 6,642 10/19/2023
1.0.64 2,876 10/18/2023
1.0.63 2,798 10/17/2023
1.0.62 3,374 10/16/2023
1.0.61 6,172 10/13/2023
1.0.60 3,626 10/12/2023
1.0.59 11,323 9/18/2023
1.0.58 298 9/18/2023
1.0.57 7,643 9/14/2023
1.0.56 7,149 8/31/2023
1.0.55 3,631 8/30/2023
1.0.54 3,101 8/29/2023
1.0.53 3,024 8/28/2023
1.0.52 5,776 8/25/2023
1.0.51 3,248 8/24/2023
1.0.50 7,869 8/21/2023
1.0.49 3,193 8/18/2023
1.0.48 2,963 8/17/2023
1.0.47 5,487 8/16/2023
1.0.46 9,022 8/10/2023
1.0.45 3,141 8/9/2023
1.0.44 5,266 8/8/2023
1.0.43 4,438 8/7/2023
1.0.42 4,641 8/4/2023
1.0.41 8,538 7/13/2023
1.0.40 5,703 7/11/2023
1.0.39 3,454 7/10/2023
1.0.38 4,336 7/7/2023
1.0.37 355 7/7/2023
1.0.36 11,978 6/30/2023
1.0.35 6,160 6/28/2023
1.0.34 6,305 6/27/2023
1.0.33 7,285 6/26/2023
1.0.32 4,345 6/23/2023
1.0.31 8,807 6/21/2023
1.0.30 9,219 6/15/2023
1.0.29 3,639 6/14/2023
1.0.28 9,808 6/9/2023
1.0.27 4,272 6/8/2023
1.0.26 5,205 6/7/2023
1.0.25 5,884 6/6/2023
1.0.24 378 6/6/2023
1.0.23 4,908 6/5/2023
1.0.22 16,973 5/30/2023
1.0.21 19,824 5/29/2023
1.0.20 6,853 5/26/2023
1.0.19 7,975 5/25/2023
1.0.18 8,305 5/24/2023
1.0.17 5,624 5/24/2023
1.0.16 1,683 5/23/2023
1.0.15 1,651 5/23/2023
1.0.12 3,095 5/22/2023
1.0.11 19,208 5/16/2023
1.0.10 15,820 4/20/2023
1.0.9 15,174 4/3/2023
1.0.8 1,264 4/3/2023
1.0.7 2,497 3/23/2023
1.0.5 764 3/13/2023
1.0.4 521 3/11/2023
1.0.3 426 3/11/2023
1.0.2 433 3/11/2023
1.0.1 486 3/11/2023