Soenneker.Utils.AsyncSingleton 2.1.326

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

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

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.326 1,723 7/25/2024
2.1.325 1,106 7/25/2024
2.1.324 921 7/25/2024
2.1.323 145 7/24/2024
2.1.322 384 7/24/2024
2.1.321 199 7/24/2024
2.1.320 5,253 7/20/2024
2.1.319 7,765 7/14/2024
2.1.318 3,110 7/14/2024
2.1.317 4,904 7/10/2024
2.1.316 2,139 7/10/2024
2.1.315 2,057 7/10/2024
2.1.314 1,143 7/10/2024
2.1.313 713 7/10/2024
2.1.312 218 7/10/2024
2.1.311 1,825 7/10/2024
2.1.310 963 7/9/2024
2.1.308 1,988 7/9/2024
2.1.307 56 7/9/2024
2.1.306 2,095 7/9/2024
2.1.305 4,921 7/9/2024
2.1.304 4,046 7/9/2024
2.1.303 1,902 7/9/2024
2.1.302 57 7/9/2024
2.1.301 1,042 7/9/2024
2.1.300 4,331 7/8/2024
2.1.299 254 7/8/2024
2.1.298 62 7/8/2024
2.1.297 64 7/8/2024
2.1.296 6,018 7/8/2024
2.1.295 1,100 7/7/2024
2.1.294 3,530 7/7/2024
2.1.293 81 7/7/2024
2.1.292 1,011 7/7/2024
2.1.291 2,192 7/7/2024
2.1.290 7,301 7/3/2024
2.1.289 2,275 7/3/2024
2.1.288 2,063 7/3/2024
2.1.287 554 7/3/2024
2.1.286 3,954 7/2/2024
2.1.283 2,500 6/30/2024
2.1.282 1,679 6/28/2024
2.1.281 160 6/28/2024
2.1.279 5,477 6/22/2024
2.1.278 6,240 6/15/2024
2.1.277 843 6/15/2024
2.1.276 4,872 6/14/2024
2.1.275 7,795 6/1/2024
2.1.274 1,243 6/1/2024
2.1.273 773 6/1/2024
2.1.272 6,727 5/31/2024
2.1.271 4,213 5/29/2024
2.1.270 4,819 5/28/2024
2.1.269 2,698 5/27/2024
2.1.268 5,020 5/26/2024
2.1.267 4,940 5/26/2024
2.1.266 221 5/26/2024
2.1.265 1,803 5/25/2024
2.1.264 1,323 5/25/2024
2.1.263 1,195 5/25/2024
2.1.262 76 5/25/2024
2.1.261 974 5/25/2024
2.1.260 74 5/25/2024
2.1.259 3,499 5/25/2024
2.1.258 74 5/25/2024
2.1.257 6,335 5/23/2024
2.1.256 2,416 5/23/2024
2.1.255 1,754 5/22/2024
2.1.254 1,313 5/22/2024
2.1.253 541 5/22/2024
2.1.252 72 5/22/2024
2.1.251 72 5/22/2024
2.1.250 2,583 5/22/2024
2.1.249 6,623 5/18/2024
2.1.248 1,389 5/17/2024
2.1.247 2,329 5/17/2024
2.1.246 3,706 5/16/2024
2.1.245 926 5/15/2024
2.1.244 2,651 5/15/2024
2.1.243 5,357 5/12/2024
2.1.242 2,957 5/3/2024
2.1.241 3,352 4/29/2024
2.1.240 1,971 4/29/2024
2.1.239 3,754 4/28/2024
2.1.238 612 4/28/2024
2.1.237 706 4/28/2024
2.1.236 2,816 4/28/2024
2.1.235 388 4/28/2024
2.1.234 3,741 4/28/2024
2.1.233 803 4/28/2024
2.1.232 3,545 4/27/2024
2.1.231 75 4/27/2024
2.1.230 7,134 4/19/2024
2.1.229 4,392 4/18/2024
2.1.228 4,619 4/12/2024
2.1.227 730 4/12/2024
2.1.226 1,157 4/12/2024
2.1.225 978 4/12/2024
2.1.224 672 4/12/2024
2.1.223 974 4/12/2024
2.1.222 376 4/12/2024
2.1.221 83 4/12/2024
2.1.220 2,570 4/10/2024
2.1.219 9,943 4/10/2024
2.1.218 477 4/10/2024
2.1.217 5,448 4/2/2024
2.1.216 894 4/1/2024
2.1.215 5,195 3/29/2024
2.1.214 3,749 3/25/2024
2.1.213 439 3/25/2024
2.1.212 5,322 3/20/2024
2.1.211 3,652 3/19/2024
2.1.210 2,199 3/19/2024
2.1.209 2,395 3/18/2024
2.1.208 5,387 3/15/2024
2.1.207 3,683 3/13/2024
2.1.206 1,394 3/13/2024
2.1.205 1,830 3/13/2024
2.1.204 131 3/13/2024
2.1.203 114 3/13/2024
2.1.202 1,180 3/13/2024
2.1.201 122 3/13/2024
2.1.200 2,684 3/12/2024
2.1.199 3,392 3/12/2024
2.1.198 4,350 3/11/2024
2.1.197 3,042 3/11/2024
2.1.196 3,254 3/10/2024
2.1.195 4,301 3/8/2024
2.1.194 403 3/8/2024
2.1.193 3,078 3/8/2024
2.1.192 3,938 3/6/2024
2.1.191 3,977 3/4/2024
2.1.190 2,175 3/4/2024
2.1.189 4,594 3/2/2024
2.1.188 1,145 3/2/2024
2.1.187 1,406 3/2/2024
2.1.186 843 3/2/2024
2.1.185 555 3/2/2024
2.1.184 2,956 2/29/2024
2.1.183 985 2/29/2024
2.1.182 1,505 2/29/2024
2.1.181 2,909 2/26/2024
2.1.180 11,740 2/25/2024
2.1.179 1,400 2/25/2024
2.1.178 4,639 2/23/2024
2.1.177 4,466 2/22/2024
2.1.176 1,217 2/22/2024
2.1.175 1,430 2/21/2024
2.1.174 2,417 2/21/2024
2.1.173 2,166 2/21/2024
2.1.172 2,739 2/21/2024
2.1.171 1,151 2/21/2024
2.1.170 299 2/21/2024
2.1.169 2,603 2/21/2024
2.1.168 740 2/20/2024
2.1.167 170 2/20/2024
2.1.166 175 2/20/2024
2.1.165 3,338 2/20/2024
2.1.164 2,473 2/20/2024
2.1.163 2,412 2/20/2024
2.1.162 5,111 2/19/2024
2.1.161 4,077 2/17/2024
2.1.160 1,697 2/17/2024
2.1.159 1,153 2/16/2024
2.1.158 880 2/16/2024
2.1.157 1,469 2/16/2024
2.1.156 2,344 2/16/2024
2.1.155 2,627 2/16/2024
2.1.154 204 2/16/2024
2.1.153 1,296 2/16/2024
2.1.152 209 2/16/2024
2.1.151 198 2/16/2024
2.1.150 4,632 2/14/2024
2.1.149 1,966 2/13/2024
2.1.148 2,342 2/13/2024
2.1.147 2,807 2/13/2024
2.1.146 2,699 2/13/2024
2.1.145 3,733 2/12/2024
2.1.144 599 2/11/2024
2.1.143 4,100 2/11/2024
2.1.142 2,326 2/11/2024
2.1.141 4,786 2/10/2024
2.1.140 552 2/9/2024
2.1.139 4,439 2/9/2024
2.1.138 2,753 2/9/2024
2.1.137 738 2/8/2024
2.1.136 3,533 2/8/2024
2.1.135 1,431 2/8/2024
2.1.134 7,682 2/8/2024
2.1.133 268 2/8/2024
2.1.132 205 2/8/2024
2.1.131 4,039 2/7/2024
2.1.130 1,560 2/7/2024
2.1.129 2,711 2/7/2024
2.1.128 894 2/7/2024
2.1.127 812 2/6/2024
2.1.126 2,142 2/6/2024
2.1.125 241 2/6/2024
2.1.124 5,746 2/5/2024
2.1.123 3,782 2/4/2024
2.1.122 4,047 2/2/2024
2.1.121 4,894 1/31/2024
2.1.120 4,773 1/29/2024
2.1.119 2,792 1/29/2024
2.1.118 1,920 1/29/2024
2.1.117 3,157 1/28/2024
2.1.116 4,056 1/28/2024
2.1.115 2,366 1/28/2024
2.1.114 1,313 1/28/2024
2.1.113 1,946 1/27/2024
2.1.112 1,625 1/27/2024
2.1.111 4,305 1/27/2024
2.1.110 1,983 1/27/2024
2.1.109 5,237 1/27/2024
2.1.108 1,285 1/26/2024
2.1.107 1,675 1/26/2024
2.1.106 2,233 1/26/2024
2.1.105 3,975 1/26/2024
2.1.104 1,906 1/26/2024
2.1.103 999 1/26/2024
2.1.102 3,530 1/25/2024
2.1.101 2,739 1/25/2024
2.1.100 1,349 1/25/2024
2.1.99 4,708 1/25/2024
2.1.98 4,219 1/19/2024
2.1.97 4,568 1/15/2024
2.1.96 2,145 1/15/2024
2.1.95 1,602 1/15/2024
2.1.94 4,232 1/15/2024
2.1.93 4,327 1/15/2024
2.1.92 4,208 1/14/2024
2.1.91 5,166 1/13/2024
2.1.90 4,357 1/12/2024
2.1.89 4,218 1/11/2024
2.1.88 5,894 1/7/2024
2.1.87 4,633 1/5/2024
2.1.86 2,117 1/5/2024
2.1.85 2,583 1/5/2024
2.1.84 4,987 1/3/2024
2.1.83 3,043 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,116 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,461 12/24/2023
2.1.70 4,406 12/23/2023
2.1.69 2,286 12/23/2023
2.1.68 1,350 12/23/2023
2.1.67 3,259 12/23/2023
2.1.66 263 12/23/2023
2.1.65 6,413 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 967 12/10/2023
2.1.53 6,843 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,468 12/9/2023
2.1.44 271 12/9/2023
2.1.43 3,700 12/9/2023
2.1.42 5,657 12/6/2023
2.1.41 1,043 12/6/2023
2.1.40 1,420 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 260 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,261 12/4/2023
2.1.28 2,242 11/27/2023
2.1.27 1,089 11/26/2023
2.1.26 2,767 11/23/2023
2.1.25 2,353 11/23/2023
2.1.24 2,870 11/23/2023
2.1.23 272 11/23/2023
2.1.22 5,653 11/20/2023
2.1.21 2,752 11/20/2023
2.1.20 4,241 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 921 11/15/2023
2.0.77 286 11/15/2023
2.0.76 2,304 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,704 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,521 8/28/2023
1.0.52 4,995 8/25/2023
1.0.51 2,703 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,930 8/16/2023
1.0.46 7,687 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,829 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,668 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,860 5/30/2023
1.0.21 18,286 5/29/2023
1.0.20 6,264 5/26/2023
1.0.19 7,310 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 730 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 461 3/11/2023