Soenneker.Utils.AsyncSingleton 2.1.402

Prefix Reserved
dotnet add package Soenneker.Utils.AsyncSingleton --version 2.1.402                
NuGet\Install-Package Soenneker.Utils.AsyncSingleton -Version 2.1.402                
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.402" />                
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.402                
#r "nuget: Soenneker.Utils.AsyncSingleton, 2.1.402"                
#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.402

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

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.402 1,434 10/3/2024
2.1.401 384 10/3/2024
2.1.400 944 10/3/2024
2.1.399 3,989 10/2/2024
2.1.398 1,542 10/2/2024
2.1.397 5,393 10/1/2024
2.1.396 607 10/1/2024
2.1.395 3,326 9/30/2024
2.1.394 6,846 9/29/2024
2.1.393 2,510 9/29/2024
2.1.392 2,424 9/29/2024
2.1.391 6,634 9/27/2024
2.1.390 4,689 9/27/2024
2.1.389 131 9/27/2024
2.1.388 707 9/27/2024
2.1.387 1,717 9/27/2024
2.1.386 74 9/27/2024
2.1.385 10,418 9/26/2024
2.1.384 9,130 9/26/2024
2.1.383 3,970 9/26/2024
2.1.382 11,392 9/23/2024
2.1.381 2,851 9/23/2024
2.1.380 4,930 9/23/2024
2.1.379 4,917 9/23/2024
2.1.378 3,700 9/23/2024
2.1.377 717 9/23/2024
2.1.376 1,838 9/23/2024
2.1.375 66 9/23/2024
2.1.374 13,360 9/17/2024
2.1.373 638 9/17/2024
2.1.372 2,692 9/17/2024
2.1.371 2,697 9/17/2024
2.1.370 3,078 9/17/2024
2.1.369 4,197 9/17/2024
2.1.368 4,677 9/17/2024
2.1.367 14,707 9/16/2024
2.1.366 7,828 9/12/2024
2.1.365 3,019 9/11/2024
2.1.363 8,865 9/11/2024
2.1.362 17,103 9/10/2024
2.1.361 696 9/10/2024
2.1.360 1,012 9/10/2024
2.1.359 891 9/10/2024
2.1.358 3,637 9/9/2024
2.1.357 1,492 9/9/2024
2.1.356 6,238 9/9/2024
2.1.355 1,716 9/9/2024
2.1.354 6,947 9/9/2024
2.1.353 13,398 9/7/2024
2.1.352 9,846 9/6/2024
2.1.351 5,093 9/5/2024
2.1.350 5,106 9/5/2024
2.1.349 532 9/5/2024
2.1.348 115 9/5/2024
2.1.347 8,986 9/5/2024
2.1.346 992 9/4/2024
2.1.345 13,540 9/3/2024
2.1.344 6,078 9/3/2024
2.1.343 4,505 9/3/2024
2.1.342 8,643 8/29/2024
2.1.341 7,222 8/26/2024
2.1.340 7,645 8/21/2024
2.1.339 2,800 8/21/2024
2.1.338 1,625 8/20/2024
2.1.337 5,767 8/20/2024
2.1.336 96 8/20/2024
2.1.335 99 8/20/2024
2.1.334 9,726 8/19/2024
2.1.333 9,443 8/15/2024
2.1.332 9,434 8/13/2024
2.1.331 7,867 8/6/2024
2.1.330 4,312 8/6/2024
2.1.329 6,535 8/1/2024
2.1.328 1,335 8/1/2024
2.1.327 601 8/1/2024
2.1.326 9,441 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,887 7/20/2024
2.1.319 11,661 7/14/2024
2.1.318 4,437 7/14/2024
2.1.317 6,756 7/10/2024
2.1.316 2,937 7/10/2024
2.1.315 2,725 7/10/2024
2.1.314 1,576 7/10/2024
2.1.313 992 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,738 7/9/2024
2.1.307 81 7/9/2024
2.1.306 2,908 7/9/2024
2.1.305 6,753 7/9/2024
2.1.304 5,661 7/9/2024
2.1.303 2,717 7/9/2024
2.1.302 80 7/9/2024
2.1.301 2,299 7/9/2024
2.1.300 6,079 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,344 7/8/2024
2.1.295 1,618 7/7/2024
2.1.294 5,055 7/7/2024
2.1.293 104 7/7/2024
2.1.292 1,425 7/7/2024
2.1.291 3,060 7/7/2024
2.1.290 10,221 7/3/2024
2.1.289 3,257 7/3/2024
2.1.288 2,914 7/3/2024
2.1.287 816 7/3/2024
2.1.286 5,626 7/2/2024
2.1.283 3,515 6/30/2024
2.1.282 2,351 6/28/2024
2.1.281 224 6/28/2024
2.1.279 7,616 6/22/2024
2.1.278 8,550 6/15/2024
2.1.277 1,153 6/15/2024
2.1.276 6,720 6/14/2024
2.1.275 10,693 6/1/2024
2.1.274 1,712 6/1/2024
2.1.273 1,079 6/1/2024
2.1.272 9,376 5/31/2024
2.1.271 5,853 5/29/2024
2.1.270 6,672 5/28/2024
2.1.269 3,734 5/27/2024
2.1.268 6,925 5/26/2024
2.1.267 6,843 5/26/2024
2.1.266 294 5/26/2024
2.1.265 2,492 5/25/2024
2.1.264 1,799 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,846 5/25/2024
2.1.258 89 5/25/2024
2.1.257 8,678 5/23/2024
2.1.256 3,428 5/23/2024
2.1.255 2,431 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,599 5/22/2024
2.1.249 9,233 5/18/2024
2.1.248 1,926 5/17/2024
2.1.247 3,309 5/17/2024
2.1.246 5,177 5/16/2024
2.1.245 1,323 5/15/2024
2.1.244 3,767 5/15/2024
2.1.243 7,735 5/12/2024
2.1.242 4,203 5/3/2024
2.1.241 4,720 4/29/2024
2.1.240 2,685 4/29/2024
2.1.239 5,174 4/28/2024
2.1.238 835 4/28/2024
2.1.237 955 4/28/2024
2.1.236 3,899 4/28/2024
2.1.235 530 4/28/2024
2.1.234 5,154 4/28/2024
2.1.233 1,087 4/28/2024
2.1.232 4,863 4/27/2024
2.1.231 94 4/27/2024
2.1.230 9,801 4/19/2024
2.1.229 6,074 4/18/2024
2.1.228 6,350 4/12/2024
2.1.227 1,005 4/12/2024
2.1.226 1,610 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,866 4/10/2024
2.1.218 661 4/10/2024
2.1.217 7,552 4/2/2024
2.1.216 1,302 4/1/2024
2.1.215 7,248 3/29/2024
2.1.214 5,272 3/25/2024
2.1.213 591 3/25/2024
2.1.212 7,348 3/20/2024
2.1.211 4,968 3/19/2024
2.1.210 2,998 3/19/2024
2.1.209 3,312 3/18/2024
2.1.208 7,305 3/15/2024
2.1.207 4,961 3/13/2024
2.1.206 1,901 3/13/2024
2.1.205 2,453 3/13/2024
2.1.204 148 3/13/2024
2.1.203 129 3/13/2024
2.1.202 1,637 3/13/2024
2.1.201 143 3/13/2024
2.1.200 3,564 3/12/2024
2.1.199 4,570 3/12/2024
2.1.198 5,976 3/11/2024
2.1.197 4,156 3/11/2024
2.1.196 4,466 3/10/2024
2.1.195 5,773 3/8/2024
2.1.194 519 3/8/2024
2.1.193 4,149 3/8/2024
2.1.192 5,360 3/6/2024
2.1.191 5,357 3/4/2024
2.1.190 3,031 3/4/2024
2.1.189 6,076 3/2/2024
2.1.188 1,541 3/2/2024
2.1.187 1,910 3/2/2024
2.1.186 1,078 3/2/2024
2.1.185 743 3/2/2024
2.1.184 4,031 2/29/2024
2.1.183 1,323 2/29/2024
2.1.182 2,041 2/29/2024
2.1.181 3,938 2/26/2024
2.1.180 15,222 2/25/2024
2.1.179 1,793 2/25/2024
2.1.178 5,989 2/23/2024
2.1.177 5,811 2/22/2024
2.1.176 1,606 2/22/2024
2.1.175 1,945 2/21/2024
2.1.174 3,149 2/21/2024
2.1.173 2,840 2/21/2024
2.1.172 3,553 2/21/2024
2.1.171 1,528 2/21/2024
2.1.170 338 2/21/2024
2.1.169 3,289 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,371 2/20/2024
2.1.164 3,275 2/20/2024
2.1.163 3,171 2/20/2024
2.1.162 6,671 2/19/2024
2.1.161 5,317 2/17/2024
2.1.160 2,198 2/17/2024
2.1.159 1,567 2/16/2024
2.1.158 1,146 2/16/2024
2.1.157 1,931 2/16/2024
2.1.156 2,977 2/16/2024
2.1.155 3,427 2/16/2024
2.1.154 225 2/16/2024
2.1.153 1,686 2/16/2024
2.1.152 227 2/16/2024
2.1.151 221 2/16/2024
2.1.150 5,895 2/14/2024
2.1.149 2,495 2/13/2024
2.1.148 3,007 2/13/2024
2.1.147 3,628 2/13/2024
2.1.146 3,489 2/13/2024
2.1.145 4,820 2/12/2024
2.1.144 749 2/11/2024
2.1.143 5,245 2/11/2024
2.1.142 2,957 2/11/2024
2.1.141 6,126 2/10/2024
2.1.140 753 2/9/2024
2.1.139 5,592 2/9/2024
2.1.138 3,602 2/9/2024
2.1.137 942 2/8/2024
2.1.136 4,500 2/8/2024
2.1.135 1,827 2/8/2024
2.1.134 10,437 2/8/2024
2.1.133 297 2/8/2024
2.1.132 227 2/8/2024
2.1.131 5,127 2/7/2024
2.1.130 2,036 2/7/2024
2.1.129 3,507 2/7/2024
2.1.128 1,134 2/7/2024
2.1.127 993 2/6/2024
2.1.126 2,788 2/6/2024
2.1.125 263 2/6/2024
2.1.124 7,390 2/5/2024
2.1.123 4,826 2/4/2024
2.1.122 5,135 2/2/2024
2.1.121 6,105 1/31/2024
2.1.120 6,007 1/29/2024
2.1.119 3,611 1/29/2024
2.1.118 2,432 1/29/2024
2.1.117 3,879 1/28/2024
2.1.116 5,140 1/28/2024
2.1.115 2,922 1/28/2024
2.1.114 1,701 1/28/2024
2.1.113 2,320 1/27/2024
2.1.112 2,049 1/27/2024
2.1.111 5,359 1/27/2024
2.1.110 2,697 1/27/2024
2.1.109 6,430 1/27/2024
2.1.108 1,660 1/26/2024
2.1.107 2,095 1/26/2024
2.1.106 2,726 1/26/2024
2.1.105 4,940 1/26/2024
2.1.104 2,344 1/26/2024
2.1.103 1,300 1/26/2024
2.1.102 4,409 1/25/2024
2.1.101 3,503 1/25/2024
2.1.100 1,695 1/25/2024
2.1.99 5,670 1/25/2024
2.1.98 5,454 1/19/2024
2.1.97 5,658 1/15/2024
2.1.96 2,577 1/15/2024
2.1.95 2,026 1/15/2024
2.1.94 5,140 1/15/2024
2.1.93 5,273 1/15/2024
2.1.92 5,110 1/14/2024
2.1.91 6,264 1/13/2024
2.1.90 5,250 1/12/2024
2.1.89 5,143 1/11/2024
2.1.88 7,115 1/7/2024
2.1.87 5,667 1/5/2024
2.1.86 2,521 1/5/2024
2.1.85 3,217 1/5/2024
2.1.84 6,061 1/3/2024
2.1.83 3,695 1/1/2024
2.1.82 5,032 12/28/2023
2.1.81 2,016 12/28/2023
2.1.80 2,048 12/28/2023
2.1.79 4,514 12/27/2023
2.1.78 2,129 12/27/2023
2.1.77 283 12/27/2023
2.1.76 8,696 12/25/2023
2.1.75 4,779 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,860 12/24/2023
2.1.70 5,357 12/23/2023
2.1.69 2,871 12/23/2023
2.1.68 1,694 12/23/2023
2.1.67 3,858 12/23/2023
2.1.66 280 12/23/2023
2.1.65 8,122 12/19/2023
2.1.64 2,231 12/19/2023
2.1.63 5,498 12/12/2023
2.1.62 454 12/12/2023
2.1.61 2,708 12/11/2023
2.1.60 2,202 12/11/2023
2.1.59 1,221 12/11/2023
2.1.58 1,648 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,165 12/10/2023
2.1.52 1,849 12/9/2023
2.1.51 1,041 12/9/2023
2.1.50 1,600 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,480 12/9/2023
2.1.42 6,735 12/6/2023
2.1.41 1,229 12/6/2023
2.1.40 1,757 12/6/2023
2.1.39 3,966 12/5/2023
2.1.38 1,997 12/5/2023
2.1.37 1,125 12/5/2023
2.1.36 2,861 12/5/2023
2.1.35 283 12/5/2023
2.1.34 2,430 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,804 12/4/2023
2.1.28 2,890 11/27/2023
2.1.27 1,353 11/26/2023
2.1.26 3,396 11/23/2023
2.1.25 2,932 11/23/2023
2.1.24 3,577 11/23/2023
2.1.23 292 11/23/2023
2.1.22 7,007 11/20/2023
2.1.21 3,382 11/20/2023
2.1.20 5,478 11/19/2023
2.1.19 3,007 11/19/2023
2.1.18 4,149 11/19/2023
2.1.17 1,104 11/18/2023
2.1.16 5,378 11/18/2023
2.1.15 1,302 11/18/2023
2.1.14 3,422 11/18/2023
2.1.13 747 11/18/2023
2.1.12 3,556 11/17/2023
2.1.11 2,925 11/17/2023
2.1.10 2,172 11/17/2023
2.1.9 399 11/17/2023
2.1.8 3,460 11/17/2023
2.1.7 2,001 11/17/2023
2.1.6 2,522 11/17/2023
2.1.5 1,721 11/17/2023
2.1.4 580 11/17/2023
2.1.3 3,276 11/16/2023
2.0.78 1,119 11/15/2023
2.0.77 309 11/15/2023
2.0.76 2,934 11/15/2023
2.0.2 315 11/16/2023
2.0.1 277 11/16/2023
1.0.75 4,222 11/13/2023
1.0.74 6,077 11/10/2023
1.0.73 4,779 11/9/2023
1.0.72 3,246 11/8/2023
1.0.71 4,985 11/7/2023
1.0.70 2,472 11/6/2023
1.0.69 3,097 11/3/2023
1.0.68 5,601 11/2/2023
1.0.67 3,413 11/1/2023
1.0.66 10,889 10/26/2023
1.0.65 6,665 10/19/2023
1.0.64 2,894 10/18/2023
1.0.63 2,803 10/17/2023
1.0.62 3,392 10/16/2023
1.0.61 6,189 10/13/2023
1.0.60 3,626 10/12/2023
1.0.59 11,384 9/18/2023
1.0.58 298 9/18/2023
1.0.57 7,670 9/14/2023
1.0.56 7,159 8/31/2023
1.0.55 3,631 8/30/2023
1.0.54 3,105 8/29/2023
1.0.53 3,024 8/28/2023
1.0.52 5,780 8/25/2023
1.0.51 3,248 8/24/2023
1.0.50 7,876 8/21/2023
1.0.49 3,197 8/18/2023
1.0.48 2,963 8/17/2023
1.0.47 5,491 8/16/2023
1.0.46 9,030 8/10/2023
1.0.45 3,150 8/9/2023
1.0.44 5,270 8/8/2023
1.0.43 4,451 8/7/2023
1.0.42 4,645 8/4/2023
1.0.41 8,562 7/13/2023
1.0.40 5,703 7/11/2023
1.0.39 3,463 7/10/2023
1.0.38 4,345 7/7/2023
1.0.37 355 7/7/2023
1.0.36 11,986 6/30/2023
1.0.35 6,165 6/28/2023
1.0.34 6,309 6/27/2023
1.0.33 7,301 6/26/2023
1.0.32 4,350 6/23/2023
1.0.31 8,822 6/21/2023
1.0.30 9,230 6/15/2023
1.0.29 3,643 6/14/2023
1.0.28 9,812 6/9/2023
1.0.27 4,272 6/8/2023
1.0.26 5,222 6/7/2023
1.0.25 5,884 6/6/2023
1.0.24 378 6/6/2023
1.0.23 4,918 6/5/2023
1.0.22 16,977 5/30/2023
1.0.21 19,834 5/29/2023
1.0.20 6,853 5/26/2023
1.0.19 7,977 5/25/2023
1.0.18 8,314 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,222 5/16/2023
1.0.10 15,820 4/20/2023
1.0.9 15,182 4/3/2023
1.0.8 1,264 4/3/2023
1.0.7 2,506 3/23/2023
1.0.5 764 3/13/2023
1.0.4 523 3/11/2023
1.0.3 426 3/11/2023
1.0.2 433 3/11/2023
1.0.1 486 3/11/2023