Soenneker.Utils.AsyncSingleton 2.1.254

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

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

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,635 9/17/2024
2.1.373 376 9/17/2024
2.1.372 1,612 9/17/2024
2.1.371 1,564 9/17/2024
2.1.370 1,857 9/17/2024
2.1.369 2,450 9/17/2024
2.1.368 2,884 9/17/2024
2.1.367 9,459 9/16/2024
2.1.366 5,801 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,315 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 93 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,862 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,493 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,638 4/12/2024
2.1.227 741 4/12/2024
2.1.226 1,169 4/12/2024
2.1.225 986 4/12/2024
2.1.224 681 4/12/2024
2.1.223 998 4/12/2024
2.1.222 380 4/12/2024
2.1.221 87 4/12/2024
2.1.220 2,591 4/10/2024
2.1.219 10,195 4/10/2024
2.1.218 484 4/10/2024
2.1.217 5,506 4/2/2024
2.1.216 922 4/1/2024
2.1.215 5,248 3/29/2024
2.1.214 3,794 3/25/2024
2.1.213 445 3/25/2024
2.1.212 5,351 3/20/2024
2.1.211 3,688 3/19/2024
2.1.210 2,219 3/19/2024
2.1.209 2,421 3/18/2024
2.1.208 5,420 3/15/2024
2.1.207 3,723 3/13/2024
2.1.206 1,413 3/13/2024
2.1.205 1,852 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,708 3/12/2024
2.1.199 3,442 3/12/2024
2.1.198 4,451 3/11/2024
2.1.197 3,090 3/11/2024
2.1.196 3,264 3/10/2024
2.1.195 4,328 3/8/2024
2.1.194 408 3/8/2024
2.1.193 3,102 3/8/2024
2.1.192 3,970 3/6/2024
2.1.191 4,023 3/4/2024
2.1.190 2,231 3/4/2024
2.1.189 4,651 3/2/2024
2.1.188 1,158 3/2/2024
2.1.187 1,423 3/2/2024
2.1.186 846 3/2/2024
2.1.185 568 3/2/2024
2.1.184 2,996 2/29/2024
2.1.183 1,000 2/29/2024
2.1.182 1,527 2/29/2024
2.1.181 2,952 2/26/2024
2.1.180 11,801 2/25/2024
2.1.179 1,415 2/25/2024
2.1.178 4,668 2/23/2024
2.1.177 4,503 2/22/2024
2.1.176 1,226 2/22/2024
2.1.175 1,448 2/21/2024
2.1.174 2,437 2/21/2024
2.1.173 2,195 2/21/2024
2.1.172 2,769 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,379 2/20/2024
2.1.164 2,523 2/20/2024
2.1.163 2,448 2/20/2024
2.1.162 5,158 2/19/2024
2.1.161 4,121 2/17/2024
2.1.160 1,721 2/17/2024
2.1.159 1,197 2/16/2024
2.1.158 909 2/16/2024
2.1.157 1,491 2/16/2024
2.1.156 2,384 2/16/2024
2.1.155 2,681 2/16/2024
2.1.154 210 2/16/2024
2.1.153 1,307 2/16/2024
2.1.152 215 2/16/2024
2.1.151 204 2/16/2024
2.1.150 4,688 2/14/2024
2.1.149 1,985 2/13/2024
2.1.148 2,377 2/13/2024
2.1.147 2,843 2/13/2024
2.1.146 2,733 2/13/2024
2.1.145 3,791 2/12/2024
2.1.144 614 2/11/2024
2.1.143 4,164 2/11/2024
2.1.142 2,351 2/11/2024
2.1.141 4,838 2/10/2024
2.1.140 565 2/9/2024
2.1.139 4,467 2/9/2024
2.1.138 2,803 2/9/2024
2.1.137 751 2/8/2024
2.1.136 3,577 2/8/2024
2.1.135 1,442 2/8/2024
2.1.134 7,717 2/8/2024
2.1.133 275 2/8/2024
2.1.132 211 2/8/2024
2.1.131 4,062 2/7/2024
2.1.130 1,580 2/7/2024
2.1.129 2,742 2/7/2024
2.1.128 902 2/7/2024
2.1.127 819 2/6/2024
2.1.126 2,160 2/6/2024
2.1.125 249 2/6/2024
2.1.124 5,788 2/5/2024
2.1.123 3,833 2/4/2024
2.1.122 4,105 2/2/2024
2.1.121 4,949 1/31/2024
2.1.120 4,812 1/29/2024
2.1.119 2,824 1/29/2024
2.1.118 1,943 1/29/2024
2.1.117 3,190 1/28/2024
2.1.116 4,096 1/28/2024
2.1.115 2,388 1/28/2024
2.1.114 1,330 1/28/2024
2.1.113 1,961 1/27/2024
2.1.112 1,637 1/27/2024
2.1.111 4,374 1/27/2024
2.1.110 2,038 1/27/2024
2.1.109 5,290 1/27/2024
2.1.108 1,306 1/26/2024
2.1.107 1,681 1/26/2024
2.1.106 2,281 1/26/2024
2.1.105 4,010 1/26/2024
2.1.104 1,924 1/26/2024
2.1.103 1,009 1/26/2024
2.1.102 3,545 1/25/2024
2.1.101 2,762 1/25/2024
2.1.100 1,367 1/25/2024
2.1.99 4,726 1/25/2024
2.1.98 4,253 1/19/2024
2.1.97 4,603 1/15/2024
2.1.96 2,160 1/15/2024
2.1.95 1,625 1/15/2024
2.1.94 4,256 1/15/2024
2.1.93 4,345 1/15/2024
2.1.92 4,222 1/14/2024
2.1.91 5,192 1/13/2024
2.1.90 4,382 1/12/2024
2.1.89 4,244 1/11/2024
2.1.88 5,920 1/7/2024
2.1.87 4,653 1/5/2024
2.1.86 2,132 1/5/2024
2.1.85 2,612 1/5/2024
2.1.84 5,013 1/3/2024
2.1.83 3,064 1/1/2024
2.1.82 4,176 12/28/2023
2.1.81 1,700 12/28/2023
2.1.80 1,655 12/28/2023
2.1.79 3,784 12/27/2023
2.1.78 1,734 12/27/2023
2.1.77 265 12/27/2023
2.1.76 7,163 12/25/2023
2.1.75 3,987 12/25/2023
2.1.74 2,006 12/25/2023
2.1.73 544 12/25/2023
2.1.72 293 12/25/2023
2.1.71 5,654 12/24/2023
2.1.70 4,479 12/23/2023
2.1.69 2,355 12/23/2023
2.1.68 1,362 12/23/2023
2.1.67 3,313 12/23/2023
2.1.66 268 12/23/2023
2.1.65 6,616 12/19/2023
2.1.64 1,888 12/19/2023
2.1.63 4,563 12/12/2023
2.1.62 400 12/12/2023
2.1.61 2,294 12/11/2023
2.1.60 1,862 12/11/2023
2.1.59 1,089 12/11/2023
2.1.58 1,372 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,991 12/10/2023
2.1.52 1,575 12/9/2023
2.1.51 892 12/9/2023
2.1.50 1,363 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,524 12/9/2023
2.1.44 276 12/9/2023
2.1.43 3,793 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,340 12/5/2023
2.1.38 1,678 12/5/2023
2.1.37 968 12/5/2023
2.1.36 2,441 12/5/2023
2.1.35 265 12/5/2023
2.1.34 2,085 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,284 11/27/2023
2.1.27 1,118 11/26/2023
2.1.26 2,833 11/23/2023
2.1.25 2,417 11/23/2023
2.1.24 2,959 11/23/2023
2.1.23 277 11/23/2023
2.1.22 5,786 11/20/2023
2.1.21 2,813 11/20/2023
2.1.20 4,355 11/19/2023
2.1.19 2,489 11/19/2023
2.1.18 3,472 11/19/2023
2.1.17 923 11/18/2023
2.1.16 4,359 11/18/2023
2.1.15 1,158 11/18/2023
2.1.14 2,877 11/18/2023
2.1.13 701 11/18/2023
2.1.12 2,932 11/17/2023
2.1.11 2,433 11/17/2023
2.1.10 1,729 11/17/2023
2.1.9 329 11/17/2023
2.1.8 2,988 11/17/2023
2.1.7 1,616 11/17/2023
2.1.6 2,042 11/17/2023
2.1.5 1,280 11/17/2023
2.1.4 468 11/17/2023
2.1.3 2,673 11/16/2023
2.0.78 928 11/15/2023
2.0.77 291 11/15/2023
2.0.76 2,409 11/15/2023
2.0.2 297 11/16/2023
2.0.1 264 11/16/2023
1.0.75 3,454 11/13/2023
1.0.74 5,026 11/10/2023
1.0.73 4,046 11/9/2023
1.0.72 2,755 11/8/2023
1.0.71 4,271 11/7/2023
1.0.70 2,035 11/6/2023
1.0.69 2,593 11/3/2023
1.0.68 4,924 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,481 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