Soenneker.Utils.AsyncSingleton 1.0.58

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 1.0.58                
NuGet\Install-Package Soenneker.Utils.AsyncSingleton -Version 1.0.58                
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="1.0.58" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Soenneker.Utils.AsyncSingleton --version 1.0.58                
#r "nuget: Soenneker.Utils.AsyncSingleton, 1.0.58"                
#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=1.0.58

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

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

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 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.391 0 9/27/2024
2.1.390 0 9/27/2024
2.1.389 0 9/27/2024
2.1.388 11 9/27/2024
2.1.387 60 9/27/2024
2.1.386 18 9/27/2024
2.1.385 1,469 9/26/2024
2.1.384 3,283 9/26/2024
2.1.383 1,550 9/26/2024
2.1.382 5,827 9/23/2024
2.1.381 2,323 9/23/2024
2.1.380 4,137 9/23/2024
2.1.379 4,081 9/23/2024
2.1.378 3,220 9/23/2024
2.1.377 675 9/23/2024
2.1.376 1,621 9/23/2024
2.1.375 64 9/23/2024
2.1.374 12,265 9/17/2024
2.1.373 593 9/17/2024
2.1.372 2,551 9/17/2024
2.1.371 2,517 9/17/2024
2.1.370 2,920 9/17/2024
2.1.369 3,912 9/17/2024
2.1.368 4,406 9/17/2024
2.1.367 13,642 9/16/2024
2.1.366 7,337 9/12/2024
2.1.365 2,804 9/11/2024
2.1.363 8,444 9/11/2024
2.1.362 16,130 9/10/2024
2.1.361 649 9/10/2024
2.1.360 951 9/10/2024
2.1.359 833 9/10/2024
2.1.358 3,419 9/9/2024
2.1.357 1,403 9/9/2024
2.1.356 5,988 9/9/2024
2.1.355 1,614 9/9/2024
2.1.354 6,642 9/9/2024
2.1.353 12,648 9/7/2024
2.1.352 9,268 9/6/2024
2.1.351 4,827 9/5/2024
2.1.350 4,817 9/5/2024
2.1.349 465 9/5/2024
2.1.348 113 9/5/2024
2.1.347 8,463 9/5/2024
2.1.346 942 9/4/2024
2.1.345 12,849 9/3/2024
2.1.344 5,758 9/3/2024
2.1.343 4,268 9/3/2024
2.1.342 8,141 8/29/2024
2.1.341 6,776 8/26/2024
2.1.340 7,135 8/21/2024
2.1.339 2,633 8/21/2024
2.1.338 1,551 8/20/2024
2.1.337 5,394 8/20/2024
2.1.336 96 8/20/2024
2.1.335 99 8/20/2024
2.1.334 9,067 8/19/2024
2.1.333 8,821 8/15/2024
2.1.332 8,794 8/13/2024
2.1.331 7,393 8/6/2024
2.1.330 4,007 8/6/2024
2.1.329 6,100 8/1/2024
2.1.328 1,227 8/1/2024
2.1.327 540 8/1/2024
2.1.326 8,749 7/25/2024
2.1.325 1,805 7/25/2024
2.1.324 1,603 7/25/2024
2.1.323 242 7/24/2024
2.1.322 648 7/24/2024
2.1.321 299 7/24/2024
2.1.320 8,176 7/20/2024
2.1.319 10,800 7/14/2024
2.1.318 4,132 7/14/2024
2.1.317 6,355 7/10/2024
2.1.316 2,667 7/10/2024
2.1.315 2,629 7/10/2024
2.1.314 1,472 7/10/2024
2.1.313 930 7/10/2024
2.1.312 296 7/10/2024
2.1.311 2,453 7/10/2024
2.1.310 1,273 7/9/2024
2.1.308 2,565 7/9/2024
2.1.307 81 7/9/2024
2.1.306 2,773 7/9/2024
2.1.305 6,309 7/9/2024
2.1.304 5,316 7/9/2024
2.1.303 2,594 7/9/2024
2.1.302 80 7/9/2024
2.1.301 1,859 7/9/2024
2.1.300 5,674 7/8/2024
2.1.299 337 7/8/2024
2.1.298 83 7/8/2024
2.1.297 90 7/8/2024
2.1.296 7,745 7/8/2024
2.1.295 1,482 7/7/2024
2.1.294 4,720 7/7/2024
2.1.293 104 7/7/2024
2.1.292 1,328 7/7/2024
2.1.291 2,912 7/7/2024
2.1.290 9,600 7/3/2024
2.1.289 3,037 7/3/2024
2.1.288 2,720 7/3/2024
2.1.287 742 7/3/2024
2.1.286 5,259 7/2/2024
2.1.283 3,288 6/30/2024
2.1.282 2,191 6/28/2024
2.1.281 220 6/28/2024
2.1.279 7,099 6/22/2024
2.1.278 8,007 6/15/2024
2.1.277 1,103 6/15/2024
2.1.276 6,309 6/14/2024
2.1.275 10,049 6/1/2024
2.1.274 1,638 6/1/2024
2.1.273 1,014 6/1/2024
2.1.272 8,753 5/31/2024
2.1.271 5,502 5/29/2024
2.1.270 6,216 5/28/2024
2.1.269 3,506 5/27/2024
2.1.268 6,458 5/26/2024
2.1.267 6,355 5/26/2024
2.1.266 290 5/26/2024
2.1.265 2,366 5/25/2024
2.1.264 1,692 5/25/2024
2.1.263 1,513 5/25/2024
2.1.262 96 5/25/2024
2.1.261 1,234 5/25/2024
2.1.260 94 5/25/2024
2.1.259 4,567 5/25/2024
2.1.258 89 5/25/2024
2.1.257 8,102 5/23/2024
2.1.256 3,187 5/23/2024
2.1.255 2,316 5/22/2024
2.1.254 1,684 5/22/2024
2.1.253 718 5/22/2024
2.1.252 88 5/22/2024
2.1.251 87 5/22/2024
2.1.250 3,385 5/22/2024
2.1.249 8,613 5/18/2024
2.1.248 1,839 5/17/2024
2.1.247 3,131 5/17/2024
2.1.246 4,790 5/16/2024
2.1.245 1,192 5/15/2024
2.1.244 3,514 5/15/2024
2.1.243 7,156 5/12/2024
2.1.242 3,908 5/3/2024
2.1.241 4,380 4/29/2024
2.1.240 2,568 4/29/2024
2.1.239 4,813 4/28/2024
2.1.238 767 4/28/2024
2.1.237 920 4/28/2024
2.1.236 3,613 4/28/2024
2.1.235 516 4/28/2024
2.1.234 4,839 4/28/2024
2.1.233 1,040 4/28/2024
2.1.232 4,504 4/27/2024
2.1.231 94 4/27/2024
2.1.230 9,064 4/19/2024
2.1.229 5,646 4/18/2024
2.1.228 5,930 4/12/2024
2.1.227 972 4/12/2024
2.1.226 1,518 4/12/2024
2.1.225 1,297 4/12/2024
2.1.224 908 4/12/2024
2.1.223 1,321 4/12/2024
2.1.222 477 4/12/2024
2.1.221 101 4/12/2024
2.1.220 3,415 4/10/2024
2.1.219 12,981 4/10/2024
2.1.218 627 4/10/2024
2.1.217 7,051 4/2/2024
2.1.216 1,221 4/1/2024
2.1.215 6,792 3/29/2024
2.1.214 4,936 3/25/2024
2.1.213 559 3/25/2024
2.1.212 6,861 3/20/2024
2.1.211 4,720 3/19/2024
2.1.210 2,852 3/19/2024
2.1.209 3,143 3/18/2024
2.1.208 6,906 3/15/2024
2.1.207 4,717 3/13/2024
2.1.206 1,790 3/13/2024
2.1.205 2,355 3/13/2024
2.1.204 148 3/13/2024
2.1.203 129 3/13/2024
2.1.202 1,543 3/13/2024
2.1.201 143 3/13/2024
2.1.200 3,424 3/12/2024
2.1.199 4,339 3/12/2024
2.1.198 5,736 3/11/2024
2.1.197 3,919 3/11/2024
2.1.196 4,230 3/10/2024
2.1.195 5,505 3/8/2024
2.1.194 502 3/8/2024
2.1.193 3,972 3/8/2024
2.1.192 5,071 3/6/2024
2.1.191 5,088 3/4/2024
2.1.190 2,885 3/4/2024
2.1.189 5,836 3/2/2024
2.1.188 1,458 3/2/2024
2.1.187 1,788 3/2/2024
2.1.186 1,038 3/2/2024
2.1.185 704 3/2/2024
2.1.184 3,814 2/29/2024
2.1.183 1,249 2/29/2024
2.1.182 1,928 2/29/2024
2.1.181 3,766 2/26/2024
2.1.180 14,692 2/25/2024
2.1.179 1,740 2/25/2024
2.1.178 5,791 2/23/2024
2.1.177 5,580 2/22/2024
2.1.176 1,529 2/22/2024
2.1.175 1,858 2/21/2024
2.1.174 3,046 2/21/2024
2.1.173 2,768 2/21/2024
2.1.172 3,430 2/21/2024
2.1.171 1,464 2/21/2024
2.1.170 338 2/21/2024
2.1.169 3,188 2/21/2024
2.1.168 948 2/20/2024
2.1.167 187 2/20/2024
2.1.166 195 2/20/2024
2.1.165 4,199 2/20/2024
2.1.164 3,159 2/20/2024
2.1.163 3,069 2/20/2024
2.1.162 6,430 2/19/2024
2.1.161 5,154 2/17/2024
2.1.160 2,115 2/17/2024
2.1.159 1,524 2/16/2024
2.1.158 1,115 2/16/2024
2.1.157 1,842 2/16/2024
2.1.156 2,864 2/16/2024
2.1.155 3,286 2/16/2024
2.1.154 225 2/16/2024
2.1.153 1,624 2/16/2024
2.1.152 227 2/16/2024
2.1.151 221 2/16/2024
2.1.150 5,717 2/14/2024
2.1.149 2,418 2/13/2024
2.1.148 2,883 2/13/2024
2.1.147 3,528 2/13/2024
2.1.146 3,356 2/13/2024
2.1.145 4,658 2/12/2024
2.1.144 726 2/11/2024
2.1.143 5,039 2/11/2024
2.1.142 2,842 2/11/2024
2.1.141 5,878 2/10/2024
2.1.140 721 2/9/2024
2.1.139 5,397 2/9/2024
2.1.138 3,486 2/9/2024
2.1.137 898 2/8/2024
2.1.136 4,342 2/8/2024
2.1.135 1,762 2/8/2024
2.1.134 9,510 2/8/2024
2.1.133 297 2/8/2024
2.1.132 227 2/8/2024
2.1.131 4,947 2/7/2024
2.1.130 1,961 2/7/2024
2.1.129 3,355 2/7/2024
2.1.128 1,083 2/7/2024
2.1.127 969 2/6/2024
2.1.126 2,656 2/6/2024
2.1.125 263 2/6/2024
2.1.124 7,085 2/5/2024
2.1.123 4,638 2/4/2024
2.1.122 4,938 2/2/2024
2.1.121 5,887 1/31/2024
2.1.120 5,782 1/29/2024
2.1.119 3,444 1/29/2024
2.1.118 2,334 1/29/2024
2.1.117 3,749 1/28/2024
2.1.116 4,950 1/28/2024
2.1.115 2,850 1/28/2024
2.1.114 1,635 1/28/2024
2.1.113 2,238 1/27/2024
2.1.112 1,955 1/27/2024
2.1.111 5,220 1/27/2024
2.1.110 2,553 1/27/2024
2.1.109 6,223 1/27/2024
2.1.108 1,619 1/26/2024
2.1.107 1,988 1/26/2024
2.1.106 2,690 1/26/2024
2.1.105 4,814 1/26/2024
2.1.104 2,261 1/26/2024
2.1.103 1,247 1/26/2024
2.1.102 4,241 1/25/2024
2.1.101 3,363 1/25/2024
2.1.100 1,632 1/25/2024
2.1.99 5,485 1/25/2024
2.1.98 5,243 1/19/2024
2.1.97 5,451 1/15/2024
2.1.96 2,516 1/15/2024
2.1.95 1,954 1/15/2024
2.1.94 4,990 1/15/2024
2.1.93 5,133 1/15/2024
2.1.92 4,957 1/14/2024
2.1.91 6,055 1/13/2024
2.1.90 5,076 1/12/2024
2.1.89 5,005 1/11/2024
2.1.88 6,894 1/7/2024
2.1.87 5,506 1/5/2024
2.1.86 2,460 1/5/2024
2.1.85 3,102 1/5/2024
2.1.84 5,862 1/3/2024
2.1.83 3,581 1/1/2024
2.1.82 4,879 12/28/2023
2.1.81 1,949 12/28/2023
2.1.80 1,950 12/28/2023
2.1.79 4,423 12/27/2023
2.1.78 2,047 12/27/2023
2.1.77 282 12/27/2023
2.1.76 8,436 12/25/2023
2.1.75 4,646 12/25/2023
2.1.74 2,372 12/25/2023
2.1.73 646 12/25/2023
2.1.72 308 12/25/2023
2.1.71 6,630 12/24/2023
2.1.70 5,208 12/23/2023
2.1.69 2,776 12/23/2023
2.1.68 1,642 12/23/2023
2.1.67 3,758 12/23/2023
2.1.66 279 12/23/2023
2.1.65 7,903 12/19/2023
2.1.64 2,181 12/19/2023
2.1.63 5,351 12/12/2023
2.1.62 444 12/12/2023
2.1.61 2,637 12/11/2023
2.1.60 2,139 12/11/2023
2.1.59 1,200 12/11/2023
2.1.58 1,600 12/11/2023
2.1.57 783 12/10/2023
2.1.56 771 12/10/2023
2.1.55 1,750 12/10/2023
2.1.54 1,108 12/10/2023
2.1.53 8,030 12/10/2023
2.1.52 1,809 12/9/2023
2.1.51 1,027 12/9/2023
2.1.50 1,559 12/9/2023
2.1.49 2,421 12/9/2023
2.1.48 254 12/9/2023
2.1.47 1,195 12/9/2023
2.1.46 328 12/9/2023
2.1.45 2,799 12/9/2023
2.1.44 287 12/9/2023
2.1.43 4,370 12/9/2023
2.1.42 6,582 12/6/2023
2.1.41 1,200 12/6/2023
2.1.40 1,703 12/6/2023
2.1.39 3,852 12/5/2023
2.1.38 1,949 12/5/2023
2.1.37 1,106 12/5/2023
2.1.36 2,808 12/5/2023
2.1.35 282 12/5/2023
2.1.34 2,375 12/5/2023
2.1.33 291 12/5/2023
2.1.32 1,556 12/4/2023
2.1.31 1,505 12/4/2023
2.1.30 318 12/4/2023
2.1.29 8,596 12/4/2023
2.1.28 2,814 11/27/2023
2.1.27 1,311 11/26/2023
2.1.26 3,313 11/23/2023
2.1.25 2,838 11/23/2023
2.1.24 3,480 11/23/2023
2.1.23 291 11/23/2023
2.1.22 6,813 11/20/2023
2.1.21 3,308 11/20/2023
2.1.20 5,307 11/19/2023
2.1.19 2,913 11/19/2023
2.1.18 4,025 11/19/2023
2.1.17 1,080 11/18/2023
2.1.16 5,158 11/18/2023
2.1.15 1,272 11/18/2023
2.1.14 3,328 11/18/2023
2.1.13 734 11/18/2023
2.1.12 3,445 11/17/2023
2.1.11 2,871 11/17/2023
2.1.10 2,103 11/17/2023
2.1.9 380 11/17/2023
2.1.8 3,393 11/17/2023
2.1.7 1,951 11/17/2023
2.1.6 2,428 11/17/2023
2.1.5 1,638 11/17/2023
2.1.4 579 11/17/2023
2.1.3 3,115 11/16/2023
2.0.78 1,100 11/15/2023
2.0.77 308 11/15/2023
2.0.76 2,851 11/15/2023
2.0.2 314 11/16/2023
2.0.1 276 11/16/2023
1.0.75 4,067 11/13/2023
1.0.74 5,890 11/10/2023
1.0.73 4,681 11/9/2023
1.0.72 3,170 11/8/2023
1.0.71 4,900 11/7/2023
1.0.70 2,398 11/6/2023
1.0.69 3,005 11/3/2023
1.0.68 5,494 11/2/2023
1.0.67 3,352 11/1/2023
1.0.66 10,502 10/26/2023
1.0.65 6,483 10/19/2023
1.0.64 2,828 10/18/2023
1.0.63 2,714 10/17/2023
1.0.62 3,299 10/16/2023
1.0.61 6,069 10/13/2023
1.0.60 3,583 10/12/2023
1.0.59 11,030 9/18/2023
1.0.58 297 9/18/2023
1.0.57 7,499 9/14/2023
1.0.56 6,997 8/31/2023
1.0.55 3,546 8/30/2023
1.0.54 3,046 8/29/2023
1.0.53 2,972 8/28/2023
1.0.52 5,672 8/25/2023
1.0.51 3,162 8/24/2023
1.0.50 7,717 8/21/2023
1.0.49 3,114 8/18/2023
1.0.48 2,902 8/17/2023
1.0.47 5,404 8/16/2023
1.0.46 8,853 8/10/2023
1.0.45 3,058 8/9/2023
1.0.44 5,205 8/8/2023
1.0.43 4,345 8/7/2023
1.0.42 4,553 8/4/2023
1.0.41 8,345 7/13/2023
1.0.40 5,596 7/11/2023
1.0.39 3,378 7/10/2023
1.0.38 4,259 7/7/2023
1.0.37 354 7/7/2023
1.0.36 11,760 6/30/2023
1.0.35 6,045 6/28/2023
1.0.34 6,233 6/27/2023
1.0.33 7,189 6/26/2023
1.0.32 4,257 6/23/2023
1.0.31 8,705 6/21/2023
1.0.30 9,073 6/15/2023
1.0.29 3,583 6/14/2023
1.0.28 9,669 6/9/2023
1.0.27 4,189 6/8/2023
1.0.26 5,122 6/7/2023
1.0.25 5,782 6/6/2023
1.0.24 377 6/6/2023
1.0.23 4,825 6/5/2023
1.0.22 16,574 5/30/2023
1.0.21 19,721 5/29/2023
1.0.20 6,768 5/26/2023
1.0.19 7,905 5/25/2023
1.0.18 8,232 5/24/2023
1.0.17 5,576 5/24/2023
1.0.16 1,603 5/23/2023
1.0.15 1,643 5/23/2023
1.0.12 3,005 5/22/2023
1.0.11 18,937 5/16/2023
1.0.10 15,507 4/20/2023
1.0.9 14,863 4/3/2023
1.0.8 1,263 4/3/2023
1.0.7 2,492 3/23/2023
1.0.5 763 3/13/2023
1.0.4 520 3/11/2023
1.0.3 425 3/11/2023
1.0.2 430 3/11/2023
1.0.1 485 3/11/2023