Soenneker.Utils.AsyncSingleton 2.1.144

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.144                
NuGet\Install-Package Soenneker.Utils.AsyncSingleton -Version 2.1.144                
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.144" />                
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.144                
#r "nuget: Soenneker.Utils.AsyncSingleton, 2.1.144"                
#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.144

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

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 (23)

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.374 2,560 9/17/2024
2.1.373 374 9/17/2024
2.1.372 1,593 9/17/2024
2.1.371 1,547 9/17/2024
2.1.370 1,835 9/17/2024
2.1.369 2,427 9/17/2024
2.1.368 2,863 9/17/2024
2.1.367 9,398 9/16/2024
2.1.366 5,797 9/12/2024
2.1.365 2,226 9/11/2024
2.1.363 6,826 9/11/2024
2.1.362 13,077 9/10/2024
2.1.361 520 9/10/2024
2.1.360 760 9/10/2024
2.1.359 679 9/10/2024
2.1.358 2,755 9/9/2024
2.1.357 1,125 9/9/2024
2.1.356 4,849 9/9/2024
2.1.355 1,311 9/9/2024
2.1.354 5,347 9/9/2024
2.1.353 10,312 9/7/2024
2.1.352 7,373 9/6/2024
2.1.351 3,840 9/5/2024
2.1.350 3,836 9/5/2024
2.1.349 405 9/5/2024
2.1.348 90 9/5/2024
2.1.347 6,792 9/5/2024
2.1.346 756 9/4/2024
2.1.345 10,229 9/3/2024
2.1.344 4,456 9/3/2024
2.1.343 3,289 9/3/2024
2.1.342 6,370 8/29/2024
2.1.341 5,325 8/26/2024
2.1.340 5,563 8/21/2024
2.1.339 2,012 8/21/2024
2.1.338 1,168 8/20/2024
2.1.337 4,157 8/20/2024
2.1.336 82 8/20/2024
2.1.335 84 8/20/2024
2.1.334 7,083 8/19/2024
2.1.333 6,979 8/15/2024
2.1.332 7,004 8/13/2024
2.1.331 5,860 8/6/2024
2.1.330 3,109 8/6/2024
2.1.329 4,569 8/1/2024
2.1.328 921 8/1/2024
2.1.327 421 8/1/2024
2.1.326 6,525 7/25/2024
2.1.325 1,369 7/25/2024
2.1.324 1,166 7/25/2024
2.1.323 187 7/24/2024
2.1.322 465 7/24/2024
2.1.321 229 7/24/2024
2.1.320 6,093 7/20/2024
2.1.319 8,206 7/14/2024
2.1.318 3,125 7/14/2024
2.1.317 4,915 7/10/2024
2.1.316 2,155 7/10/2024
2.1.315 2,068 7/10/2024
2.1.314 1,151 7/10/2024
2.1.313 725 7/10/2024
2.1.312 231 7/10/2024
2.1.311 1,837 7/10/2024
2.1.310 977 7/9/2024
2.1.308 1,999 7/9/2024
2.1.307 66 7/9/2024
2.1.306 2,106 7/9/2024
2.1.305 4,934 7/9/2024
2.1.304 4,059 7/9/2024
2.1.303 1,914 7/9/2024
2.1.302 69 7/9/2024
2.1.301 1,473 7/9/2024
2.1.300 4,344 7/8/2024
2.1.299 264 7/8/2024
2.1.298 72 7/8/2024
2.1.297 74 7/8/2024
2.1.296 6,035 7/8/2024
2.1.295 1,125 7/7/2024
2.1.294 3,541 7/7/2024
2.1.293 91 7/7/2024
2.1.292 1,022 7/7/2024
2.1.291 2,205 7/7/2024
2.1.290 7,312 7/3/2024
2.1.289 2,289 7/3/2024
2.1.288 2,074 7/3/2024
2.1.287 568 7/3/2024
2.1.286 3,969 7/2/2024
2.1.283 2,510 6/30/2024
2.1.282 1,692 6/28/2024
2.1.281 168 6/28/2024
2.1.279 5,497 6/22/2024
2.1.278 6,270 6/15/2024
2.1.277 850 6/15/2024
2.1.276 4,886 6/14/2024
2.1.275 7,812 6/1/2024
2.1.274 1,249 6/1/2024
2.1.273 777 6/1/2024
2.1.272 6,742 5/31/2024
2.1.271 4,223 5/29/2024
2.1.270 4,829 5/28/2024
2.1.269 2,707 5/27/2024
2.1.268 5,029 5/26/2024
2.1.267 4,950 5/26/2024
2.1.266 225 5/26/2024
2.1.265 1,808 5/25/2024
2.1.264 1,328 5/25/2024
2.1.263 1,199 5/25/2024
2.1.262 80 5/25/2024
2.1.261 978 5/25/2024
2.1.260 78 5/25/2024
2.1.259 3,504 5/25/2024
2.1.258 78 5/25/2024
2.1.257 6,341 5/23/2024
2.1.256 2,436 5/23/2024
2.1.255 1,765 5/22/2024
2.1.254 1,325 5/22/2024
2.1.253 545 5/22/2024
2.1.252 76 5/22/2024
2.1.251 76 5/22/2024
2.1.250 2,597 5/22/2024
2.1.249 6,637 5/18/2024
2.1.248 1,392 5/17/2024
2.1.247 2,336 5/17/2024
2.1.246 3,712 5/16/2024
2.1.245 929 5/15/2024
2.1.244 2,654 5/15/2024
2.1.243 5,360 5/12/2024
2.1.242 2,973 5/3/2024
2.1.241 3,363 4/29/2024
2.1.240 1,977 4/29/2024
2.1.239 3,757 4/28/2024
2.1.238 615 4/28/2024
2.1.237 709 4/28/2024
2.1.236 2,819 4/28/2024
2.1.235 391 4/28/2024
2.1.234 3,778 4/28/2024
2.1.233 806 4/28/2024
2.1.232 3,556 4/27/2024
2.1.231 78 4/27/2024
2.1.230 7,143 4/19/2024
2.1.229 4,396 4/18/2024
2.1.228 4,634 4/12/2024
2.1.227 736 4/12/2024
2.1.226 1,161 4/12/2024
2.1.225 981 4/12/2024
2.1.224 676 4/12/2024
2.1.223 978 4/12/2024
2.1.222 380 4/12/2024
2.1.221 87 4/12/2024
2.1.220 2,576 4/10/2024
2.1.219 10,172 4/10/2024
2.1.218 484 4/10/2024
2.1.217 5,475 4/2/2024
2.1.216 898 4/1/2024
2.1.215 5,223 3/29/2024
2.1.214 3,771 3/25/2024
2.1.213 445 3/25/2024
2.1.212 5,327 3/20/2024
2.1.211 3,662 3/19/2024
2.1.210 2,210 3/19/2024
2.1.209 2,405 3/18/2024
2.1.208 5,406 3/15/2024
2.1.207 3,702 3/13/2024
2.1.206 1,399 3/13/2024
2.1.205 1,841 3/13/2024
2.1.204 136 3/13/2024
2.1.203 119 3/13/2024
2.1.202 1,200 3/13/2024
2.1.201 127 3/13/2024
2.1.200 2,699 3/12/2024
2.1.199 3,408 3/12/2024
2.1.198 4,393 3/11/2024
2.1.197 3,053 3/11/2024
2.1.196 3,259 3/10/2024
2.1.195 4,312 3/8/2024
2.1.194 408 3/8/2024
2.1.193 3,083 3/8/2024
2.1.192 3,949 3/6/2024
2.1.191 3,990 3/4/2024
2.1.190 2,186 3/4/2024
2.1.189 4,608 3/2/2024
2.1.188 1,148 3/2/2024
2.1.187 1,415 3/2/2024
2.1.186 846 3/2/2024
2.1.185 560 3/2/2024
2.1.184 2,982 2/29/2024
2.1.183 997 2/29/2024
2.1.182 1,513 2/29/2024
2.1.181 2,919 2/26/2024
2.1.180 11,775 2/25/2024
2.1.179 1,404 2/25/2024
2.1.178 4,645 2/23/2024
2.1.177 4,483 2/22/2024
2.1.176 1,221 2/22/2024
2.1.175 1,434 2/21/2024
2.1.174 2,421 2/21/2024
2.1.173 2,170 2/21/2024
2.1.172 2,743 2/21/2024
2.1.171 1,155 2/21/2024
2.1.170 303 2/21/2024
2.1.169 2,619 2/21/2024
2.1.168 744 2/20/2024
2.1.167 174 2/20/2024
2.1.166 179 2/20/2024
2.1.165 3,366 2/20/2024
2.1.164 2,503 2/20/2024
2.1.163 2,433 2/20/2024
2.1.162 5,132 2/19/2024
2.1.161 4,094 2/17/2024
2.1.160 1,704 2/17/2024
2.1.159 1,183 2/16/2024
2.1.158 909 2/16/2024
2.1.157 1,484 2/16/2024
2.1.156 2,379 2/16/2024
2.1.155 2,672 2/16/2024
2.1.154 210 2/16/2024
2.1.153 1,302 2/16/2024
2.1.152 215 2/16/2024
2.1.151 204 2/16/2024
2.1.150 4,654 2/14/2024
2.1.149 1,974 2/13/2024
2.1.148 2,360 2/13/2024
2.1.147 2,828 2/13/2024
2.1.146 2,713 2/13/2024
2.1.145 3,764 2/12/2024
2.1.144 606 2/11/2024
2.1.143 4,133 2/11/2024
2.1.142 2,343 2/11/2024
2.1.141 4,809 2/10/2024
2.1.140 559 2/9/2024
2.1.139 4,456 2/9/2024
2.1.138 2,772 2/9/2024
2.1.137 745 2/8/2024
2.1.136 3,551 2/8/2024
2.1.135 1,437 2/8/2024
2.1.134 7,689 2/8/2024
2.1.133 275 2/8/2024
2.1.132 211 2/8/2024
2.1.131 4,045 2/7/2024
2.1.130 1,566 2/7/2024
2.1.129 2,717 2/7/2024
2.1.128 902 2/7/2024
2.1.127 819 2/6/2024
2.1.126 2,150 2/6/2024
2.1.125 249 2/6/2024
2.1.124 5,766 2/5/2024
2.1.123 3,812 2/4/2024
2.1.122 4,089 2/2/2024
2.1.121 4,932 1/31/2024
2.1.120 4,799 1/29/2024
2.1.119 2,817 1/29/2024
2.1.118 1,926 1/29/2024
2.1.117 3,174 1/28/2024
2.1.116 4,090 1/28/2024
2.1.115 2,379 1/28/2024
2.1.114 1,326 1/28/2024
2.1.113 1,956 1/27/2024
2.1.112 1,637 1/27/2024
2.1.111 4,357 1/27/2024
2.1.110 2,038 1/27/2024
2.1.109 5,284 1/27/2024
2.1.108 1,306 1/26/2024
2.1.107 1,681 1/26/2024
2.1.106 2,264 1/26/2024
2.1.105 4,005 1/26/2024
2.1.104 1,924 1/26/2024
2.1.103 1,004 1/26/2024
2.1.102 3,542 1/25/2024
2.1.101 2,757 1/25/2024
2.1.100 1,355 1/25/2024
2.1.99 4,718 1/25/2024
2.1.98 4,242 1/19/2024
2.1.97 4,598 1/15/2024
2.1.96 2,154 1/15/2024
2.1.95 1,609 1/15/2024
2.1.94 4,244 1/15/2024
2.1.93 4,334 1/15/2024
2.1.92 4,220 1/14/2024
2.1.91 5,183 1/13/2024
2.1.90 4,374 1/12/2024
2.1.89 4,239 1/11/2024
2.1.88 5,907 1/7/2024
2.1.87 4,640 1/5/2024
2.1.86 2,124 1/5/2024
2.1.85 2,596 1/5/2024
2.1.84 5,001 1/3/2024
2.1.83 3,064 1/1/2024
2.1.82 4,168 12/28/2023
2.1.81 1,700 12/28/2023
2.1.80 1,655 12/28/2023
2.1.79 3,777 12/27/2023
2.1.78 1,725 12/27/2023
2.1.77 265 12/27/2023
2.1.76 7,158 12/25/2023
2.1.75 3,983 12/25/2023
2.1.74 2,000 12/25/2023
2.1.73 544 12/25/2023
2.1.72 293 12/25/2023
2.1.71 5,644 12/24/2023
2.1.70 4,476 12/23/2023
2.1.69 2,351 12/23/2023
2.1.68 1,357 12/23/2023
2.1.67 3,313 12/23/2023
2.1.66 268 12/23/2023
2.1.65 6,611 12/19/2023
2.1.64 1,877 12/19/2023
2.1.63 4,554 12/12/2023
2.1.62 400 12/12/2023
2.1.61 2,284 12/11/2023
2.1.60 1,857 12/11/2023
2.1.59 1,089 12/11/2023
2.1.58 1,365 12/11/2023
2.1.57 670 12/10/2023
2.1.56 666 12/10/2023
2.1.55 1,565 12/10/2023
2.1.54 974 12/10/2023
2.1.53 6,987 12/10/2023
2.1.52 1,575 12/9/2023
2.1.51 892 12/9/2023
2.1.50 1,360 12/9/2023
2.1.49 2,112 12/9/2023
2.1.48 243 12/9/2023
2.1.47 991 12/9/2023
2.1.46 316 12/9/2023
2.1.45 2,522 12/9/2023
2.1.44 276 12/9/2023
2.1.43 3,790 12/9/2023
2.1.42 5,754 12/6/2023
2.1.41 1,059 12/6/2023
2.1.40 1,458 12/6/2023
2.1.39 3,337 12/5/2023
2.1.38 1,678 12/5/2023
2.1.37 962 12/5/2023
2.1.36 2,437 12/5/2023
2.1.35 265 12/5/2023
2.1.34 2,076 12/5/2023
2.1.33 275 12/5/2023
2.1.32 1,272 12/4/2023
2.1.31 1,356 12/4/2023
2.1.30 292 12/4/2023
2.1.29 7,424 12/4/2023
2.1.28 2,276 11/27/2023
2.1.27 1,115 11/26/2023
2.1.26 2,825 11/23/2023
2.1.25 2,417 11/23/2023
2.1.24 2,951 11/23/2023
2.1.23 277 11/23/2023
2.1.22 5,782 11/20/2023
2.1.21 2,807 11/20/2023
2.1.20 4,351 11/19/2023
2.1.19 2,484 11/19/2023
2.1.18 3,467 11/19/2023
2.1.17 918 11/18/2023
2.1.16 4,353 11/18/2023
2.1.15 1,154 11/18/2023
2.1.14 2,873 11/18/2023
2.1.13 701 11/18/2023
2.1.12 2,932 11/17/2023
2.1.11 2,430 11/17/2023
2.1.10 1,724 11/17/2023
2.1.9 329 11/17/2023
2.1.8 2,982 11/17/2023
2.1.7 1,616 11/17/2023
2.1.6 2,036 11/17/2023
2.1.5 1,277 11/17/2023
2.1.4 468 11/17/2023
2.1.3 2,666 11/16/2023
2.0.78 928 11/15/2023
2.0.77 291 11/15/2023
2.0.76 2,404 11/15/2023
2.0.2 297 11/16/2023
2.0.1 264 11/16/2023
1.0.75 3,444 11/13/2023
1.0.74 5,017 11/10/2023
1.0.73 4,035 11/9/2023
1.0.72 2,755 11/8/2023
1.0.71 4,260 11/7/2023
1.0.70 2,035 11/6/2023
1.0.69 2,581 11/3/2023
1.0.68 4,920 11/2/2023
1.0.67 2,755 11/1/2023
1.0.66 8,982 10/26/2023
1.0.65 5,620 10/19/2023
1.0.64 2,553 10/18/2023
1.0.63 2,330 10/17/2023
1.0.62 2,837 10/16/2023
1.0.61 5,477 10/13/2023
1.0.60 3,149 10/12/2023
1.0.59 9,511 9/18/2023
1.0.58 287 9/18/2023
1.0.57 6,636 9/14/2023
1.0.56 6,059 8/31/2023
1.0.55 3,196 8/30/2023
1.0.54 2,627 8/29/2023
1.0.53 2,554 8/28/2023
1.0.52 5,044 8/25/2023
1.0.51 2,772 8/24/2023
1.0.50 6,728 8/21/2023
1.0.49 2,696 8/18/2023
1.0.48 2,516 8/17/2023
1.0.47 4,946 8/16/2023
1.0.46 7,823 8/10/2023
1.0.45 2,739 8/9/2023
1.0.44 4,748 8/8/2023
1.0.43 3,855 8/7/2023
1.0.42 4,090 8/4/2023
1.0.41 7,364 7/13/2023
1.0.40 5,030 7/11/2023
1.0.39 2,967 7/10/2023
1.0.38 3,854 7/7/2023
1.0.37 339 7/7/2023
1.0.36 10,516 6/30/2023
1.0.35 5,421 6/28/2023
1.0.34 5,702 6/27/2023
1.0.33 6,551 6/26/2023
1.0.32 3,811 6/23/2023
1.0.31 7,932 6/21/2023
1.0.30 8,123 6/15/2023
1.0.29 3,168 6/14/2023
1.0.28 8,710 6/9/2023
1.0.27 3,784 6/8/2023
1.0.26 4,743 6/7/2023
1.0.25 5,343 6/6/2023
1.0.24 361 6/6/2023
1.0.23 4,394 6/5/2023
1.0.22 15,026 5/30/2023
1.0.21 18,422 5/29/2023
1.0.20 6,271 5/26/2023
1.0.19 7,317 5/25/2023
1.0.18 7,722 5/24/2023
1.0.17 5,143 5/24/2023
1.0.16 1,450 5/23/2023
1.0.15 1,565 5/23/2023
1.0.12 2,711 5/22/2023
1.0.11 17,521 5/16/2023
1.0.10 14,286 4/20/2023
1.0.9 13,656 4/3/2023
1.0.8 1,206 4/3/2023
1.0.7 2,372 3/23/2023
1.0.5 735 3/13/2023
1.0.4 491 3/11/2023
1.0.3 414 3/11/2023
1.0.2 417 3/11/2023
1.0.1 464 3/11/2023