Soenneker.Utils.AsyncSingleton 2.1.279

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Soenneker.Utils.AsyncSingleton --version 2.1.279
NuGet\Install-Package Soenneker.Utils.AsyncSingleton -Version 2.1.279
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.279" />
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.279
#r "nuget: Soenneker.Utils.AsyncSingleton, 2.1.279"
#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.279

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

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

Showing the top 5 NuGet packages that depend on Soenneker.Utils.AsyncSingleton:

Package Downloads
Soenneker.Utils.MemoryStream The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

An easy modern MemoryStream utility

Soenneker.Redis.Client The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library for Redis client accessibility

Soenneker.Cosmos.Client The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library for Azure Cosmos client accessibility

Soenneker.Blob.Container The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A utility library for Azure Blob storage container operations

Soenneker.ServiceBus.Admin The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

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.279 3,269 6/22/2024
2.1.278 6,228 6/15/2024
2.1.277 836 6/15/2024
2.1.276 4,859 6/14/2024
2.1.275 7,787 6/1/2024
2.1.274 1,232 6/1/2024
2.1.273 757 6/1/2024
2.1.272 6,722 5/31/2024
2.1.271 4,208 5/29/2024
2.1.270 4,811 5/28/2024
2.1.269 2,691 5/27/2024
2.1.268 5,015 5/26/2024
2.1.267 4,936 5/26/2024
2.1.266 217 5/26/2024
2.1.265 1,799 5/25/2024
2.1.264 1,319 5/25/2024
2.1.263 1,191 5/25/2024
2.1.262 72 5/25/2024
2.1.261 970 5/25/2024
2.1.260 70 5/25/2024
2.1.259 3,495 5/25/2024
2.1.258 70 5/25/2024
2.1.257 6,331 5/23/2024
2.1.256 2,412 5/23/2024
2.1.255 1,750 5/22/2024
2.1.254 1,309 5/22/2024
2.1.253 534 5/22/2024
2.1.252 68 5/22/2024
2.1.251 68 5/22/2024
2.1.250 2,579 5/22/2024
2.1.249 6,608 5/18/2024
2.1.248 1,382 5/17/2024
2.1.247 2,325 5/17/2024
2.1.246 3,704 5/16/2024
2.1.245 924 5/15/2024
2.1.244 2,647 5/15/2024
2.1.243 5,355 5/12/2024
2.1.242 2,776 5/3/2024
2.1.241 3,345 4/29/2024
2.1.240 1,968 4/29/2024
2.1.239 3,751 4/28/2024
2.1.238 609 4/28/2024
2.1.237 703 4/28/2024
2.1.236 2,815 4/28/2024
2.1.235 387 4/28/2024
2.1.234 3,726 4/28/2024
2.1.233 800 4/28/2024
2.1.232 3,542 4/27/2024
2.1.231 72 4/27/2024
2.1.230 7,130 4/19/2024
2.1.229 4,388 4/18/2024
2.1.228 4,613 4/12/2024
2.1.227 726 4/12/2024
2.1.226 1,154 4/12/2024
2.1.225 974 4/12/2024
2.1.224 668 4/12/2024
2.1.223 970 4/12/2024
2.1.222 372 4/12/2024
2.1.221 79 4/12/2024
2.1.220 2,567 4/10/2024
2.1.219 9,893 4/10/2024
2.1.218 473 4/10/2024
2.1.217 5,441 4/2/2024
2.1.216 890 4/1/2024
2.1.215 5,190 3/29/2024
2.1.214 3,743 3/25/2024
2.1.213 437 3/25/2024
2.1.212 5,303 3/20/2024
2.1.211 3,643 3/19/2024
2.1.210 2,197 3/19/2024
2.1.209 2,389 3/18/2024
2.1.208 5,381 3/15/2024
2.1.207 3,674 3/13/2024
2.1.206 1,390 3/13/2024
2.1.205 1,824 3/13/2024
2.1.204 128 3/13/2024
2.1.203 110 3/13/2024
2.1.202 1,173 3/13/2024
2.1.201 117 3/13/2024
2.1.200 2,678 3/12/2024
2.1.199 3,387 3/12/2024
2.1.198 4,346 3/11/2024
2.1.197 3,033 3/11/2024
2.1.196 3,247 3/10/2024
2.1.195 4,293 3/8/2024
2.1.194 397 3/8/2024
2.1.193 3,074 3/8/2024
2.1.192 3,930 3/6/2024
2.1.191 3,970 3/4/2024
2.1.190 2,167 3/4/2024
2.1.189 4,584 3/2/2024
2.1.188 1,133 3/2/2024
2.1.187 1,400 3/2/2024
2.1.186 833 3/2/2024
2.1.185 547 3/2/2024
2.1.184 2,944 2/29/2024
2.1.183 983 2/29/2024
2.1.182 1,499 2/29/2024
2.1.181 2,901 2/26/2024
2.1.180 11,721 2/25/2024
2.1.179 1,392 2/25/2024
2.1.178 4,635 2/23/2024
2.1.177 4,458 2/22/2024
2.1.176 1,213 2/22/2024
2.1.175 1,424 2/21/2024
2.1.174 2,413 2/21/2024
2.1.173 2,160 2/21/2024
2.1.172 2,733 2/21/2024
2.1.171 1,143 2/21/2024
2.1.170 295 2/21/2024
2.1.169 2,599 2/21/2024
2.1.168 734 2/20/2024
2.1.167 166 2/20/2024
2.1.166 171 2/20/2024
2.1.165 3,332 2/20/2024
2.1.164 2,465 2/20/2024
2.1.163 2,408 2/20/2024
2.1.162 5,105 2/19/2024
2.1.161 4,073 2/17/2024
2.1.160 1,693 2/17/2024
2.1.159 1,150 2/16/2024
2.1.158 877 2/16/2024
2.1.157 1,465 2/16/2024
2.1.156 2,342 2/16/2024
2.1.155 2,625 2/16/2024
2.1.154 202 2/16/2024
2.1.153 1,293 2/16/2024
2.1.152 206 2/16/2024
2.1.151 194 2/16/2024
2.1.150 4,629 2/14/2024
2.1.149 1,963 2/13/2024
2.1.148 2,339 2/13/2024
2.1.147 2,804 2/13/2024
2.1.146 2,696 2/13/2024
2.1.145 3,730 2/12/2024
2.1.144 596 2/11/2024
2.1.143 4,095 2/11/2024
2.1.142 2,323 2/11/2024
2.1.141 4,783 2/10/2024
2.1.140 549 2/9/2024
2.1.139 4,436 2/9/2024
2.1.138 2,750 2/9/2024
2.1.137 735 2/8/2024
2.1.136 3,529 2/8/2024
2.1.135 1,422 2/8/2024
2.1.134 7,679 2/8/2024
2.1.133 265 2/8/2024
2.1.132 200 2/8/2024
2.1.131 4,036 2/7/2024
2.1.130 1,557 2/7/2024
2.1.129 2,708 2/7/2024
2.1.128 891 2/7/2024
2.1.127 808 2/6/2024
2.1.126 2,139 2/6/2024
2.1.125 238 2/6/2024
2.1.124 5,743 2/5/2024
2.1.123 3,779 2/4/2024
2.1.122 4,044 2/2/2024
2.1.121 4,890 1/31/2024
2.1.120 4,770 1/29/2024
2.1.119 2,789 1/29/2024
2.1.118 1,915 1/29/2024
2.1.117 3,154 1/28/2024
2.1.116 4,053 1/28/2024
2.1.115 2,356 1/28/2024
2.1.114 1,310 1/28/2024
2.1.113 1,943 1/27/2024
2.1.112 1,622 1/27/2024
2.1.111 4,297 1/27/2024
2.1.110 1,978 1/27/2024
2.1.109 5,217 1/27/2024
2.1.108 1,282 1/26/2024
2.1.107 1,672 1/26/2024
2.1.106 2,227 1/26/2024
2.1.105 3,967 1/26/2024
2.1.104 1,902 1/26/2024
2.1.103 995 1/26/2024
2.1.102 3,526 1/25/2024
2.1.101 2,735 1/25/2024
2.1.100 1,345 1/25/2024
2.1.99 4,704 1/25/2024
2.1.98 4,210 1/19/2024
2.1.97 4,564 1/15/2024
2.1.96 2,138 1/15/2024
2.1.95 1,598 1/15/2024
2.1.94 4,223 1/15/2024
2.1.93 4,315 1/15/2024
2.1.92 4,197 1/14/2024
2.1.91 5,158 1/13/2024
2.1.90 4,354 1/12/2024
2.1.89 4,217 1/11/2024
2.1.88 5,891 1/7/2024
2.1.87 4,630 1/5/2024
2.1.86 2,113 1/5/2024
2.1.85 2,580 1/5/2024
2.1.84 4,984 1/3/2024
2.1.83 3,040 1/1/2024
2.1.82 4,155 12/28/2023
2.1.81 1,688 12/28/2023
2.1.80 1,633 12/28/2023
2.1.79 3,751 12/27/2023
2.1.78 1,713 12/27/2023
2.1.77 260 12/27/2023
2.1.76 7,114 12/25/2023
2.1.75 3,915 12/25/2023
2.1.74 1,952 12/25/2023
2.1.73 537 12/25/2023
2.1.72 288 12/25/2023
2.1.71 5,459 12/24/2023
2.1.70 4,406 12/23/2023
2.1.69 2,286 12/23/2023
2.1.68 1,347 12/23/2023
2.1.67 3,259 12/23/2023
2.1.66 263 12/23/2023
2.1.65 6,410 12/19/2023
2.1.64 1,870 12/19/2023
2.1.63 4,444 12/12/2023
2.1.62 393 12/12/2023
2.1.61 2,238 12/11/2023
2.1.60 1,807 12/11/2023
2.1.59 1,079 12/11/2023
2.1.58 1,349 12/11/2023
2.1.57 663 12/10/2023
2.1.56 659 12/10/2023
2.1.55 1,558 12/10/2023
2.1.54 961 12/10/2023
2.1.53 6,839 12/10/2023
2.1.52 1,552 12/9/2023
2.1.51 885 12/9/2023
2.1.50 1,324 12/9/2023
2.1.49 2,095 12/9/2023
2.1.48 238 12/9/2023
2.1.47 968 12/9/2023
2.1.46 311 12/9/2023
2.1.45 2,460 12/9/2023
2.1.44 271 12/9/2023
2.1.43 3,696 12/9/2023
2.1.42 5,654 12/6/2023
2.1.41 1,043 12/6/2023
2.1.40 1,419 12/6/2023
2.1.39 3,263 12/5/2023
2.1.38 1,650 12/5/2023
2.1.37 955 12/5/2023
2.1.36 2,380 12/5/2023
2.1.35 259 12/5/2023
2.1.34 2,046 12/5/2023
2.1.33 270 12/5/2023
2.1.32 1,240 12/4/2023
2.1.31 1,349 12/4/2023
2.1.30 287 12/4/2023
2.1.29 7,259 12/4/2023
2.1.28 2,240 11/27/2023
2.1.27 1,089 11/26/2023
2.1.26 2,764 11/23/2023
2.1.25 2,349 11/23/2023
2.1.24 2,862 11/23/2023
2.1.23 272 11/23/2023
2.1.22 5,651 11/20/2023
2.1.21 2,752 11/20/2023
2.1.20 4,238 11/19/2023
2.1.19 2,447 11/19/2023
2.1.18 3,367 11/19/2023
2.1.17 911 11/18/2023
2.1.16 4,236 11/18/2023
2.1.15 1,129 11/18/2023
2.1.14 2,798 11/18/2023
2.1.13 694 11/18/2023
2.1.12 2,857 11/17/2023
2.1.11 2,390 11/17/2023
2.1.10 1,642 11/17/2023
2.1.9 323 11/17/2023
2.1.8 2,927 11/17/2023
2.1.7 1,576 11/17/2023
2.1.6 1,974 11/17/2023
2.1.5 1,180 11/17/2023
2.1.4 462 11/17/2023
2.1.3 2,567 11/16/2023
2.0.78 917 11/15/2023
2.0.77 286 11/15/2023
2.0.76 2,296 11/15/2023
2.0.2 292 11/16/2023
2.0.1 259 11/16/2023
1.0.75 3,352 11/13/2023
1.0.74 4,978 11/10/2023
1.0.73 4,024 11/9/2023
1.0.72 2,701 11/8/2023
1.0.71 4,210 11/7/2023
1.0.70 2,026 11/6/2023
1.0.69 2,572 11/3/2023
1.0.68 4,858 11/2/2023
1.0.67 2,700 11/1/2023
1.0.66 8,634 10/26/2023
1.0.65 5,489 10/19/2023
1.0.64 2,502 10/18/2023
1.0.63 2,300 10/17/2023
1.0.62 2,788 10/16/2023
1.0.61 5,428 10/13/2023
1.0.60 3,138 10/12/2023
1.0.59 9,300 9/18/2023
1.0.58 281 9/18/2023
1.0.57 6,521 9/14/2023
1.0.56 5,924 8/31/2023
1.0.55 3,180 8/30/2023
1.0.54 2,561 8/29/2023
1.0.53 2,520 8/28/2023
1.0.52 4,995 8/25/2023
1.0.51 2,698 8/24/2023
1.0.50 6,659 8/21/2023
1.0.49 2,582 8/18/2023
1.0.48 2,457 8/17/2023
1.0.47 4,925 8/16/2023
1.0.46 7,682 8/10/2023
1.0.45 2,696 8/9/2023
1.0.44 4,712 8/8/2023
1.0.43 3,820 8/7/2023
1.0.42 4,070 8/4/2023
1.0.41 7,209 7/13/2023
1.0.40 5,002 7/11/2023
1.0.39 2,876 7/10/2023
1.0.38 3,828 7/7/2023
1.0.37 333 7/7/2023
1.0.36 10,384 6/30/2023
1.0.35 5,347 6/28/2023
1.0.34 5,667 6/27/2023
1.0.33 6,477 6/26/2023
1.0.32 3,772 6/23/2023
1.0.31 7,831 6/21/2023
1.0.30 7,997 6/15/2023
1.0.29 3,093 6/14/2023
1.0.28 8,582 6/9/2023
1.0.27 3,775 6/8/2023
1.0.26 4,685 6/7/2023
1.0.25 5,336 6/6/2023
1.0.24 355 6/6/2023
1.0.23 4,303 6/5/2023
1.0.22 14,855 5/30/2023
1.0.21 18,278 5/29/2023
1.0.20 6,259 5/26/2023
1.0.19 7,302 5/25/2023
1.0.18 7,715 5/24/2023
1.0.17 5,138 5/24/2023
1.0.16 1,444 5/23/2023
1.0.15 1,558 5/23/2023
1.0.12 2,705 5/22/2023
1.0.11 17,513 5/16/2023
1.0.10 14,273 4/20/2023
1.0.9 13,647 4/3/2023
1.0.8 1,197 4/3/2023
1.0.7 2,360 3/23/2023
1.0.5 728 3/13/2023
1.0.4 486 3/11/2023
1.0.3 411 3/11/2023
1.0.2 414 3/11/2023
1.0.1 459 3/11/2023