Soenneker.Utils.AsyncSingleton 2.1.360

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

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

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.391 655 9/27/2024
2.1.390 1,719 9/27/2024
2.1.389 55 9/27/2024
2.1.388 280 9/27/2024
2.1.387 648 9/27/2024
2.1.386 32 9/27/2024
2.1.385 3,920 9/26/2024
2.1.384 3,548 9/26/2024
2.1.383 1,573 9/26/2024
2.1.382 6,067 9/23/2024
2.1.381 2,439 9/23/2024
2.1.380 4,292 9/23/2024
2.1.379 4,187 9/23/2024
2.1.378 3,349 9/23/2024
2.1.377 683 9/23/2024
2.1.376 1,654 9/23/2024
2.1.375 64 9/23/2024
2.1.374 12,721 9/17/2024
2.1.373 619 9/17/2024
2.1.372 2,623 9/17/2024
2.1.371 2,590 9/17/2024
2.1.370 2,969 9/17/2024
2.1.369 4,042 9/17/2024
2.1.368 4,544 9/17/2024
2.1.367 13,984 9/16/2024
2.1.366 7,551 9/12/2024
2.1.365 2,900 9/11/2024
2.1.363 8,638 9/11/2024
2.1.362 16,533 9/10/2024
2.1.361 666 9/10/2024
2.1.360 981 9/10/2024
2.1.359 851 9/10/2024
2.1.358 3,500 9/9/2024
2.1.357 1,442 9/9/2024
2.1.356 6,105 9/9/2024
2.1.355 1,650 9/9/2024
2.1.354 6,816 9/9/2024
2.1.353 12,948 9/7/2024
2.1.352 9,507 9/6/2024
2.1.351 4,957 9/5/2024
2.1.350 4,949 9/5/2024
2.1.349 514 9/5/2024
2.1.348 113 9/5/2024
2.1.347 8,666 9/5/2024
2.1.346 951 9/4/2024
2.1.345 13,178 9/3/2024
2.1.344 5,904 9/3/2024
2.1.343 4,379 9/3/2024
2.1.342 8,364 8/29/2024
2.1.341 6,968 8/26/2024
2.1.340 7,342 8/21/2024
2.1.339 2,717 8/21/2024
2.1.338 1,584 8/20/2024
2.1.337 5,538 8/20/2024
2.1.336 96 8/20/2024
2.1.335 99 8/20/2024
2.1.334 9,366 8/19/2024
2.1.333 9,095 8/15/2024
2.1.332 9,024 8/13/2024
2.1.331 7,617 8/6/2024
2.1.330 4,143 8/6/2024
2.1.329 6,306 8/1/2024
2.1.328 1,281 8/1/2024
2.1.327 582 8/1/2024
2.1.326 9,032 7/25/2024
2.1.325 1,871 7/25/2024
2.1.324 1,638 7/25/2024
2.1.323 245 7/24/2024
2.1.322 682 7/24/2024
2.1.321 316 7/24/2024
2.1.320 8,414 7/20/2024
2.1.319 11,209 7/14/2024
2.1.318 4,290 7/14/2024
2.1.317 6,561 7/10/2024
2.1.316 2,803 7/10/2024
2.1.315 2,683 7/10/2024
2.1.314 1,509 7/10/2024
2.1.313 947 7/10/2024
2.1.312 302 7/10/2024
2.1.311 2,517 7/10/2024
2.1.310 1,308 7/9/2024
2.1.308 2,618 7/9/2024
2.1.307 81 7/9/2024
2.1.306 2,813 7/9/2024
2.1.305 6,491 7/9/2024
2.1.304 5,547 7/9/2024
2.1.303 2,634 7/9/2024
2.1.302 80 7/9/2024
2.1.301 2,071 7/9/2024
2.1.300 5,829 7/8/2024
2.1.299 339 7/8/2024
2.1.298 83 7/8/2024
2.1.297 90 7/8/2024
2.1.296 8,039 7/8/2024
2.1.295 1,562 7/7/2024
2.1.294 4,875 7/7/2024
2.1.293 104 7/7/2024
2.1.292 1,374 7/7/2024
2.1.291 2,966 7/7/2024
2.1.290 9,883 7/3/2024
2.1.289 3,143 7/3/2024
2.1.288 2,811 7/3/2024
2.1.287 771 7/3/2024
2.1.286 5,413 7/2/2024
2.1.283 3,399 6/30/2024
2.1.282 2,268 6/28/2024
2.1.281 220 6/28/2024
2.1.279 7,323 6/22/2024
2.1.278 8,250 6/15/2024
2.1.277 1,132 6/15/2024
2.1.276 6,492 6/14/2024
2.1.275 10,340 6/1/2024
2.1.274 1,686 6/1/2024
2.1.273 1,039 6/1/2024
2.1.272 9,046 5/31/2024
2.1.271 5,644 5/29/2024
2.1.270 6,404 5/28/2024
2.1.269 3,622 5/27/2024
2.1.268 6,648 5/26/2024
2.1.267 6,552 5/26/2024
2.1.266 290 5/26/2024
2.1.265 2,438 5/25/2024
2.1.264 1,713 5/25/2024
2.1.263 1,562 5/25/2024
2.1.262 96 5/25/2024
2.1.261 1,317 5/25/2024
2.1.260 94 5/25/2024
2.1.259 4,669 5/25/2024
2.1.258 89 5/25/2024
2.1.257 8,350 5/23/2024
2.1.256 3,295 5/23/2024
2.1.255 2,364 5/22/2024
2.1.254 1,730 5/22/2024
2.1.253 727 5/22/2024
2.1.252 88 5/22/2024
2.1.251 87 5/22/2024
2.1.250 3,470 5/22/2024
2.1.249 8,926 5/18/2024
2.1.248 1,867 5/17/2024
2.1.247 3,206 5/17/2024
2.1.246 4,962 5/16/2024
2.1.245 1,224 5/15/2024
2.1.244 3,611 5/15/2024
2.1.243 7,455 5/12/2024
2.1.242 4,029 5/3/2024
2.1.241 4,533 4/29/2024
2.1.240 2,634 4/29/2024
2.1.239 4,951 4/28/2024
2.1.238 799 4/28/2024
2.1.237 931 4/28/2024
2.1.236 3,733 4/28/2024
2.1.235 523 4/28/2024
2.1.234 5,012 4/28/2024
2.1.233 1,040 4/28/2024
2.1.232 4,674 4/27/2024
2.1.231 94 4/27/2024
2.1.230 9,354 4/19/2024
2.1.229 5,830 4/18/2024
2.1.228 6,161 4/12/2024
2.1.227 985 4/12/2024
2.1.226 1,568 4/12/2024
2.1.225 1,325 4/12/2024
2.1.224 926 4/12/2024
2.1.223 1,330 4/12/2024
2.1.222 502 4/12/2024
2.1.221 101 4/12/2024
2.1.220 3,492 4/10/2024
2.1.219 13,334 4/10/2024
2.1.218 638 4/10/2024
2.1.217 7,299 4/2/2024
2.1.216 1,259 4/1/2024
2.1.215 6,970 3/29/2024
2.1.214 5,062 3/25/2024
2.1.213 573 3/25/2024
2.1.212 7,047 3/20/2024
2.1.211 4,801 3/19/2024
2.1.210 2,882 3/19/2024
2.1.209 3,178 3/18/2024
2.1.208 7,040 3/15/2024
2.1.207 4,805 3/13/2024
2.1.206 1,822 3/13/2024
2.1.205 2,374 3/13/2024
2.1.204 148 3/13/2024
2.1.203 129 3/13/2024
2.1.202 1,583 3/13/2024
2.1.201 143 3/13/2024
2.1.200 3,467 3/12/2024
2.1.199 4,404 3/12/2024
2.1.198 5,814 3/11/2024
2.1.197 3,979 3/11/2024
2.1.196 4,304 3/10/2024
2.1.195 5,564 3/8/2024
2.1.194 506 3/8/2024
2.1.193 4,013 3/8/2024
2.1.192 5,170 3/6/2024
2.1.191 5,156 3/4/2024
2.1.190 2,934 3/4/2024
2.1.189 5,881 3/2/2024
2.1.188 1,496 3/2/2024
2.1.187 1,814 3/2/2024
2.1.186 1,057 3/2/2024
2.1.185 711 3/2/2024
2.1.184 3,855 2/29/2024
2.1.183 1,278 2/29/2024
2.1.182 1,963 2/29/2024
2.1.181 3,810 2/26/2024
2.1.180 14,737 2/25/2024
2.1.179 1,745 2/25/2024
2.1.178 5,826 2/23/2024
2.1.177 5,605 2/22/2024
2.1.176 1,539 2/22/2024
2.1.175 1,875 2/21/2024
2.1.174 3,060 2/21/2024
2.1.173 2,776 2/21/2024
2.1.172 3,459 2/21/2024
2.1.171 1,488 2/21/2024
2.1.170 338 2/21/2024
2.1.169 3,203 2/21/2024
2.1.168 973 2/20/2024
2.1.167 187 2/20/2024
2.1.166 195 2/20/2024
2.1.165 4,217 2/20/2024
2.1.164 3,190 2/20/2024
2.1.163 3,092 2/20/2024
2.1.162 6,472 2/19/2024
2.1.161 5,188 2/17/2024
2.1.160 2,130 2/17/2024
2.1.159 1,529 2/16/2024
2.1.158 1,115 2/16/2024
2.1.157 1,868 2/16/2024
2.1.156 2,885 2/16/2024
2.1.155 3,302 2/16/2024
2.1.154 225 2/16/2024
2.1.153 1,632 2/16/2024
2.1.152 227 2/16/2024
2.1.151 221 2/16/2024
2.1.150 5,748 2/14/2024
2.1.149 2,429 2/13/2024
2.1.148 2,925 2/13/2024
2.1.147 3,535 2/13/2024
2.1.146 3,382 2/13/2024
2.1.145 4,667 2/12/2024
2.1.144 732 2/11/2024
2.1.143 5,074 2/11/2024
2.1.142 2,864 2/11/2024
2.1.141 5,914 2/10/2024
2.1.140 727 2/9/2024
2.1.139 5,420 2/9/2024
2.1.138 3,505 2/9/2024
2.1.137 898 2/8/2024
2.1.136 4,364 2/8/2024
2.1.135 1,778 2/8/2024
2.1.134 9,549 2/8/2024
2.1.133 297 2/8/2024
2.1.132 227 2/8/2024
2.1.131 4,955 2/7/2024
2.1.130 1,973 2/7/2024
2.1.129 3,374 2/7/2024
2.1.128 1,084 2/7/2024
2.1.127 975 2/6/2024
2.1.126 2,685 2/6/2024
2.1.125 263 2/6/2024
2.1.124 7,115 2/5/2024
2.1.123 4,662 2/4/2024
2.1.122 4,947 2/2/2024
2.1.121 5,910 1/31/2024
2.1.120 5,799 1/29/2024
2.1.119 3,459 1/29/2024
2.1.118 2,348 1/29/2024
2.1.117 3,761 1/28/2024
2.1.116 4,978 1/28/2024
2.1.115 2,872 1/28/2024
2.1.114 1,647 1/28/2024
2.1.113 2,238 1/27/2024
2.1.112 1,972 1/27/2024
2.1.111 5,223 1/27/2024
2.1.110 2,580 1/27/2024
2.1.109 6,244 1/27/2024
2.1.108 1,632 1/26/2024
2.1.107 2,023 1/26/2024
2.1.106 2,690 1/26/2024
2.1.105 4,825 1/26/2024
2.1.104 2,269 1/26/2024
2.1.103 1,254 1/26/2024
2.1.102 4,280 1/25/2024
2.1.101 3,375 1/25/2024
2.1.100 1,654 1/25/2024
2.1.99 5,496 1/25/2024
2.1.98 5,260 1/19/2024
2.1.97 5,470 1/15/2024
2.1.96 2,530 1/15/2024
2.1.95 1,967 1/15/2024
2.1.94 5,008 1/15/2024
2.1.93 5,144 1/15/2024
2.1.92 4,977 1/14/2024
2.1.91 6,085 1/13/2024
2.1.90 5,090 1/12/2024
2.1.89 5,024 1/11/2024
2.1.88 6,934 1/7/2024
2.1.87 5,526 1/5/2024
2.1.86 2,460 1/5/2024
2.1.85 3,120 1/5/2024
2.1.84 5,883 1/3/2024
2.1.83 3,592 1/1/2024
2.1.82 4,904 12/28/2023
2.1.81 1,964 12/28/2023
2.1.80 1,967 12/28/2023
2.1.79 4,459 12/27/2023
2.1.78 2,055 12/27/2023
2.1.77 282 12/27/2023
2.1.76 8,473 12/25/2023
2.1.75 4,669 12/25/2023
2.1.74 2,377 12/25/2023
2.1.73 667 12/25/2023
2.1.72 308 12/25/2023
2.1.71 6,659 12/24/2023
2.1.70 5,228 12/23/2023
2.1.69 2,787 12/23/2023
2.1.68 1,664 12/23/2023
2.1.67 3,783 12/23/2023
2.1.66 279 12/23/2023
2.1.65 7,927 12/19/2023
2.1.64 2,198 12/19/2023
2.1.63 5,382 12/12/2023
2.1.62 447 12/12/2023
2.1.61 2,645 12/11/2023
2.1.60 2,147 12/11/2023
2.1.59 1,208 12/11/2023
2.1.58 1,600 12/11/2023
2.1.57 783 12/10/2023
2.1.56 772 12/10/2023
2.1.55 1,767 12/10/2023
2.1.54 1,111 12/10/2023
2.1.53 8,056 12/10/2023
2.1.52 1,813 12/9/2023
2.1.51 1,030 12/9/2023
2.1.50 1,564 12/9/2023
2.1.49 2,432 12/9/2023
2.1.48 254 12/9/2023
2.1.47 1,208 12/9/2023
2.1.46 328 12/9/2023
2.1.45 2,803 12/9/2023
2.1.44 287 12/9/2023
2.1.43 4,401 12/9/2023
2.1.42 6,614 12/6/2023
2.1.41 1,206 12/6/2023
2.1.40 1,717 12/6/2023
2.1.39 3,880 12/5/2023
2.1.38 1,958 12/5/2023
2.1.37 1,118 12/5/2023
2.1.36 2,818 12/5/2023
2.1.35 282 12/5/2023
2.1.34 2,396 12/5/2023
2.1.33 291 12/5/2023
2.1.32 1,561 12/4/2023
2.1.31 1,511 12/4/2023
2.1.30 318 12/4/2023
2.1.29 8,673 12/4/2023
2.1.28 2,844 11/27/2023
2.1.27 1,320 11/26/2023
2.1.26 3,343 11/23/2023
2.1.25 2,862 11/23/2023
2.1.24 3,494 11/23/2023
2.1.23 291 11/23/2023
2.1.22 6,854 11/20/2023
2.1.21 3,341 11/20/2023
2.1.20 5,350 11/19/2023
2.1.19 2,956 11/19/2023
2.1.18 4,052 11/19/2023
2.1.17 1,089 11/18/2023
2.1.16 5,196 11/18/2023
2.1.15 1,272 11/18/2023
2.1.14 3,352 11/18/2023
2.1.13 743 11/18/2023
2.1.12 3,480 11/17/2023
2.1.11 2,886 11/17/2023
2.1.10 2,119 11/17/2023
2.1.9 380 11/17/2023
2.1.8 3,400 11/17/2023
2.1.7 1,982 11/17/2023
2.1.6 2,441 11/17/2023
2.1.5 1,658 11/17/2023
2.1.4 579 11/17/2023
2.1.3 3,151 11/16/2023
2.0.78 1,106 11/15/2023
2.0.77 308 11/15/2023
2.0.76 2,883 11/15/2023
2.0.2 314 11/16/2023
2.0.1 276 11/16/2023
1.0.75 4,113 11/13/2023
1.0.74 5,945 11/10/2023
1.0.73 4,701 11/9/2023
1.0.72 3,209 11/8/2023
1.0.71 4,924 11/7/2023
1.0.70 2,427 11/6/2023
1.0.69 3,038 11/3/2023
1.0.68 5,532 11/2/2023
1.0.67 3,365 11/1/2023
1.0.66 10,550 10/26/2023
1.0.65 6,533 10/19/2023
1.0.64 2,839 10/18/2023
1.0.63 2,739 10/17/2023
1.0.62 3,315 10/16/2023
1.0.61 6,092 10/13/2023
1.0.60 3,602 10/12/2023
1.0.59 11,067 9/18/2023
1.0.58 297 9/18/2023
1.0.57 7,518 9/14/2023
1.0.56 7,028 8/31/2023
1.0.55 3,570 8/30/2023
1.0.54 3,066 8/29/2023
1.0.53 2,992 8/28/2023
1.0.52 5,691 8/25/2023
1.0.51 3,185 8/24/2023
1.0.50 7,748 8/21/2023
1.0.49 3,148 8/18/2023
1.0.48 2,925 8/17/2023
1.0.47 5,432 8/16/2023
1.0.46 8,887 8/10/2023
1.0.45 3,089 8/9/2023
1.0.44 5,222 8/8/2023
1.0.43 4,385 8/7/2023
1.0.42 4,567 8/4/2023
1.0.41 8,387 7/13/2023
1.0.40 5,630 7/11/2023
1.0.39 3,401 7/10/2023
1.0.38 4,284 7/7/2023
1.0.37 354 7/7/2023
1.0.36 11,813 6/30/2023
1.0.35 6,088 6/28/2023
1.0.34 6,245 6/27/2023
1.0.33 7,217 6/26/2023
1.0.32 4,277 6/23/2023
1.0.31 8,732 6/21/2023
1.0.30 9,105 6/15/2023
1.0.29 3,593 6/14/2023
1.0.28 9,714 6/9/2023
1.0.27 4,209 6/8/2023
1.0.26 5,156 6/7/2023
1.0.25 5,808 6/6/2023
1.0.24 377 6/6/2023
1.0.23 4,861 6/5/2023
1.0.22 16,670 5/30/2023
1.0.21 19,761 5/29/2023
1.0.20 6,799 5/26/2023
1.0.19 7,927 5/25/2023
1.0.18 8,244 5/24/2023
1.0.17 5,595 5/24/2023
1.0.16 1,611 5/23/2023
1.0.15 1,643 5/23/2023
1.0.12 3,043 5/22/2023
1.0.11 19,012 5/16/2023
1.0.10 15,599 4/20/2023
1.0.9 14,890 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 432 3/11/2023
1.0.1 485 3/11/2023