Soenneker.Utils.AsyncSingleton 2.1.267

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

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

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.374 2,673 9/17/2024
2.1.373 376 9/17/2024
2.1.372 1,614 9/17/2024
2.1.371 1,565 9/17/2024
2.1.370 1,858 9/17/2024
2.1.369 2,451 9/17/2024
2.1.368 2,884 9/17/2024
2.1.367 9,461 9/16/2024
2.1.366 5,802 9/12/2024
2.1.365 2,226 9/11/2024
2.1.363 6,826 9/11/2024
2.1.362 13,077 9/10/2024
2.1.361 520 9/10/2024
2.1.360 760 9/10/2024
2.1.359 679 9/10/2024
2.1.358 2,755 9/9/2024
2.1.357 1,125 9/9/2024
2.1.356 4,849 9/9/2024
2.1.355 1,311 9/9/2024
2.1.354 5,347 9/9/2024
2.1.353 10,315 9/7/2024
2.1.352 7,373 9/6/2024
2.1.351 3,840 9/5/2024
2.1.350 3,836 9/5/2024
2.1.349 405 9/5/2024
2.1.348 93 9/5/2024
2.1.347 6,792 9/5/2024
2.1.346 756 9/4/2024
2.1.345 10,229 9/3/2024
2.1.344 4,456 9/3/2024
2.1.343 3,289 9/3/2024
2.1.342 6,370 8/29/2024
2.1.341 5,325 8/26/2024
2.1.340 5,563 8/21/2024
2.1.339 2,012 8/21/2024
2.1.338 1,168 8/20/2024
2.1.337 4,157 8/20/2024
2.1.336 82 8/20/2024
2.1.335 84 8/20/2024
2.1.334 7,083 8/19/2024
2.1.333 6,979 8/15/2024
2.1.332 7,004 8/13/2024
2.1.331 5,862 8/6/2024
2.1.330 3,109 8/6/2024
2.1.329 4,569 8/1/2024
2.1.328 921 8/1/2024
2.1.327 421 8/1/2024
2.1.326 6,525 7/25/2024
2.1.325 1,369 7/25/2024
2.1.324 1,166 7/25/2024
2.1.323 187 7/24/2024
2.1.322 465 7/24/2024
2.1.321 229 7/24/2024
2.1.320 6,093 7/20/2024
2.1.319 8,210 7/14/2024
2.1.318 3,125 7/14/2024
2.1.317 4,915 7/10/2024
2.1.316 2,155 7/10/2024
2.1.315 2,068 7/10/2024
2.1.314 1,151 7/10/2024
2.1.313 725 7/10/2024
2.1.312 231 7/10/2024
2.1.311 1,837 7/10/2024
2.1.310 977 7/9/2024
2.1.308 1,999 7/9/2024
2.1.307 66 7/9/2024
2.1.306 2,106 7/9/2024
2.1.305 4,934 7/9/2024
2.1.304 4,059 7/9/2024
2.1.303 1,914 7/9/2024
2.1.302 69 7/9/2024
2.1.301 1,498 7/9/2024
2.1.300 4,344 7/8/2024
2.1.299 264 7/8/2024
2.1.298 72 7/8/2024
2.1.297 74 7/8/2024
2.1.296 6,035 7/8/2024
2.1.295 1,125 7/7/2024
2.1.294 3,541 7/7/2024
2.1.293 91 7/7/2024
2.1.292 1,022 7/7/2024
2.1.291 2,205 7/7/2024
2.1.290 7,312 7/3/2024
2.1.289 2,289 7/3/2024
2.1.288 2,074 7/3/2024
2.1.287 568 7/3/2024
2.1.286 3,969 7/2/2024
2.1.283 2,510 6/30/2024
2.1.282 1,692 6/28/2024
2.1.281 168 6/28/2024
2.1.279 5,497 6/22/2024
2.1.278 6,270 6/15/2024
2.1.277 850 6/15/2024
2.1.276 4,886 6/14/2024
2.1.275 7,812 6/1/2024
2.1.274 1,249 6/1/2024
2.1.273 777 6/1/2024
2.1.272 6,742 5/31/2024
2.1.271 4,223 5/29/2024
2.1.270 4,829 5/28/2024
2.1.269 2,707 5/27/2024
2.1.268 5,029 5/26/2024
2.1.267 4,950 5/26/2024
2.1.266 225 5/26/2024
2.1.265 1,808 5/25/2024
2.1.264 1,328 5/25/2024
2.1.263 1,199 5/25/2024
2.1.262 80 5/25/2024
2.1.261 978 5/25/2024
2.1.260 78 5/25/2024
2.1.259 3,504 5/25/2024
2.1.258 78 5/25/2024
2.1.257 6,341 5/23/2024
2.1.256 2,436 5/23/2024
2.1.255 1,765 5/22/2024
2.1.254 1,325 5/22/2024
2.1.253 545 5/22/2024
2.1.252 76 5/22/2024
2.1.251 76 5/22/2024
2.1.250 2,597 5/22/2024
2.1.249 6,637 5/18/2024
2.1.248 1,392 5/17/2024
2.1.247 2,336 5/17/2024
2.1.246 3,712 5/16/2024
2.1.245 929 5/15/2024
2.1.244 2,654 5/15/2024
2.1.243 5,360 5/12/2024
2.1.242 2,973 5/3/2024
2.1.241 3,363 4/29/2024
2.1.240 1,977 4/29/2024
2.1.239 3,757 4/28/2024
2.1.238 615 4/28/2024
2.1.237 709 4/28/2024
2.1.236 2,819 4/28/2024
2.1.235 391 4/28/2024
2.1.234 3,778 4/28/2024
2.1.233 806 4/28/2024
2.1.232 3,556 4/27/2024
2.1.231 78 4/27/2024
2.1.230 7,143 4/19/2024
2.1.229 4,396 4/18/2024
2.1.228 4,638 4/12/2024
2.1.227 741 4/12/2024
2.1.226 1,169 4/12/2024
2.1.225 986 4/12/2024
2.1.224 681 4/12/2024
2.1.223 998 4/12/2024
2.1.222 380 4/12/2024
2.1.221 87 4/12/2024
2.1.220 2,591 4/10/2024
2.1.219 10,203 4/10/2024
2.1.218 484 4/10/2024
2.1.217 5,529 4/2/2024
2.1.216 929 4/1/2024
2.1.215 5,294 3/29/2024
2.1.214 3,815 3/25/2024
2.1.213 445 3/25/2024
2.1.212 5,382 3/20/2024
2.1.211 3,716 3/19/2024
2.1.210 2,234 3/19/2024
2.1.209 2,443 3/18/2024
2.1.208 5,458 3/15/2024
2.1.207 3,735 3/13/2024
2.1.206 1,417 3/13/2024
2.1.205 1,863 3/13/2024
2.1.204 136 3/13/2024
2.1.203 119 3/13/2024
2.1.202 1,209 3/13/2024
2.1.201 127 3/13/2024
2.1.200 2,729 3/12/2024
2.1.199 3,466 3/12/2024
2.1.198 4,482 3/11/2024
2.1.197 3,117 3/11/2024
2.1.196 3,286 3/10/2024
2.1.195 4,339 3/8/2024
2.1.194 408 3/8/2024
2.1.193 3,112 3/8/2024
2.1.192 3,987 3/6/2024
2.1.191 4,037 3/4/2024
2.1.190 2,249 3/4/2024
2.1.189 4,663 3/2/2024
2.1.188 1,169 3/2/2024
2.1.187 1,423 3/2/2024
2.1.186 846 3/2/2024
2.1.185 573 3/2/2024
2.1.184 3,013 2/29/2024
2.1.183 1,002 2/29/2024
2.1.182 1,529 2/29/2024
2.1.181 2,967 2/26/2024
2.1.180 11,828 2/25/2024
2.1.179 1,422 2/25/2024
2.1.178 4,672 2/23/2024
2.1.177 4,506 2/22/2024
2.1.176 1,237 2/22/2024
2.1.175 1,460 2/21/2024
2.1.174 2,448 2/21/2024
2.1.173 2,198 2/21/2024
2.1.172 2,778 2/21/2024
2.1.171 1,169 2/21/2024
2.1.170 303 2/21/2024
2.1.169 2,625 2/21/2024
2.1.168 749 2/20/2024
2.1.167 174 2/20/2024
2.1.166 179 2/20/2024
2.1.165 3,399 2/20/2024
2.1.164 2,537 2/20/2024
2.1.163 2,454 2/20/2024
2.1.162 5,184 2/19/2024
2.1.161 4,157 2/17/2024
2.1.160 1,736 2/17/2024
2.1.159 1,202 2/16/2024
2.1.158 913 2/16/2024
2.1.157 1,495 2/16/2024
2.1.156 2,387 2/16/2024
2.1.155 2,688 2/16/2024
2.1.154 210 2/16/2024
2.1.153 1,315 2/16/2024
2.1.152 215 2/16/2024
2.1.151 204 2/16/2024
2.1.150 4,716 2/14/2024
2.1.149 1,999 2/13/2024
2.1.148 2,406 2/13/2024
2.1.147 2,857 2/13/2024
2.1.146 2,762 2/13/2024
2.1.145 3,803 2/12/2024
2.1.144 616 2/11/2024
2.1.143 4,174 2/11/2024
2.1.142 2,358 2/11/2024
2.1.141 4,861 2/10/2024
2.1.140 565 2/9/2024
2.1.139 4,487 2/9/2024
2.1.138 2,830 2/9/2024
2.1.137 751 2/8/2024
2.1.136 3,599 2/8/2024
2.1.135 1,449 2/8/2024
2.1.134 7,739 2/8/2024
2.1.133 275 2/8/2024
2.1.132 211 2/8/2024
2.1.131 4,071 2/7/2024
2.1.130 1,583 2/7/2024
2.1.129 2,763 2/7/2024
2.1.128 902 2/7/2024
2.1.127 819 2/6/2024
2.1.126 2,172 2/6/2024
2.1.125 249 2/6/2024
2.1.124 5,796 2/5/2024
2.1.123 3,849 2/4/2024
2.1.122 4,105 2/2/2024
2.1.121 4,956 1/31/2024
2.1.120 4,821 1/29/2024
2.1.119 2,824 1/29/2024
2.1.118 1,943 1/29/2024
2.1.117 3,196 1/28/2024
2.1.116 4,099 1/28/2024
2.1.115 2,388 1/28/2024
2.1.114 1,330 1/28/2024
2.1.113 1,967 1/27/2024
2.1.112 1,637 1/27/2024
2.1.111 4,377 1/27/2024
2.1.110 2,045 1/27/2024
2.1.109 5,299 1/27/2024
2.1.108 1,306 1/26/2024
2.1.107 1,681 1/26/2024
2.1.106 2,281 1/26/2024
2.1.105 4,017 1/26/2024
2.1.104 1,924 1/26/2024
2.1.103 1,018 1/26/2024
2.1.102 3,545 1/25/2024
2.1.101 2,762 1/25/2024
2.1.100 1,368 1/25/2024
2.1.99 4,729 1/25/2024
2.1.98 4,259 1/19/2024
2.1.97 4,611 1/15/2024
2.1.96 2,160 1/15/2024
2.1.95 1,625 1/15/2024
2.1.94 4,256 1/15/2024
2.1.93 4,348 1/15/2024
2.1.92 4,222 1/14/2024
2.1.91 5,192 1/13/2024
2.1.90 4,382 1/12/2024
2.1.89 4,245 1/11/2024
2.1.88 5,929 1/7/2024
2.1.87 4,670 1/5/2024
2.1.86 2,138 1/5/2024
2.1.85 2,618 1/5/2024
2.1.84 5,017 1/3/2024
2.1.83 3,070 1/1/2024
2.1.82 4,189 12/28/2023
2.1.81 1,700 12/28/2023
2.1.80 1,655 12/28/2023
2.1.79 3,794 12/27/2023
2.1.78 1,744 12/27/2023
2.1.77 265 12/27/2023
2.1.76 7,202 12/25/2023
2.1.75 3,999 12/25/2023
2.1.74 2,006 12/25/2023
2.1.73 544 12/25/2023
2.1.72 293 12/25/2023
2.1.71 5,662 12/24/2023
2.1.70 4,489 12/23/2023
2.1.69 2,355 12/23/2023
2.1.68 1,371 12/23/2023
2.1.67 3,313 12/23/2023
2.1.66 268 12/23/2023
2.1.65 6,640 12/19/2023
2.1.64 1,891 12/19/2023
2.1.63 4,582 12/12/2023
2.1.62 400 12/12/2023
2.1.61 2,303 12/11/2023
2.1.60 1,872 12/11/2023
2.1.59 1,089 12/11/2023
2.1.58 1,381 12/11/2023
2.1.57 675 12/10/2023
2.1.56 666 12/10/2023
2.1.55 1,571 12/10/2023
2.1.54 979 12/10/2023
2.1.53 7,005 12/10/2023
2.1.52 1,582 12/9/2023
2.1.51 897 12/9/2023
2.1.50 1,373 12/9/2023
2.1.49 2,118 12/9/2023
2.1.48 243 12/9/2023
2.1.47 996 12/9/2023
2.1.46 316 12/9/2023
2.1.45 2,529 12/9/2023
2.1.44 276 12/9/2023
2.1.43 3,804 12/9/2023
2.1.42 5,767 12/6/2023
2.1.41 1,059 12/6/2023
2.1.40 1,466 12/6/2023
2.1.39 3,347 12/5/2023
2.1.38 1,683 12/5/2023
2.1.37 968 12/5/2023
2.1.36 2,444 12/5/2023
2.1.35 265 12/5/2023
2.1.34 2,089 12/5/2023
2.1.33 275 12/5/2023
2.1.32 1,272 12/4/2023
2.1.31 1,359 12/4/2023
2.1.30 292 12/4/2023
2.1.29 7,443 12/4/2023
2.1.28 2,287 11/27/2023
2.1.27 1,121 11/26/2023
2.1.26 2,841 11/23/2023
2.1.25 2,426 11/23/2023
2.1.24 2,964 11/23/2023
2.1.23 277 11/23/2023
2.1.22 5,799 11/20/2023
2.1.21 2,824 11/20/2023
2.1.20 4,375 11/19/2023
2.1.19 2,494 11/19/2023
2.1.18 3,484 11/19/2023
2.1.17 930 11/18/2023
2.1.16 4,380 11/18/2023
2.1.15 1,158 11/18/2023
2.1.14 2,880 11/18/2023
2.1.13 706 11/18/2023
2.1.12 2,935 11/17/2023
2.1.11 2,441 11/17/2023
2.1.10 1,738 11/17/2023
2.1.9 329 11/17/2023
2.1.8 2,996 11/17/2023
2.1.7 1,625 11/17/2023
2.1.6 2,045 11/17/2023
2.1.5 1,283 11/17/2023
2.1.4 468 11/17/2023
2.1.3 2,673 11/16/2023
2.0.78 934 11/15/2023
2.0.77 291 11/15/2023
2.0.76 2,414 11/15/2023
2.0.2 297 11/16/2023
2.0.1 264 11/16/2023
1.0.75 3,457 11/13/2023
1.0.74 5,042 11/10/2023
1.0.73 4,063 11/9/2023
1.0.72 2,762 11/8/2023
1.0.71 4,276 11/7/2023
1.0.70 2,042 11/6/2023
1.0.69 2,601 11/3/2023
1.0.68 4,936 11/2/2023
1.0.67 2,755 11/1/2023
1.0.66 8,982 10/26/2023
1.0.65 5,620 10/19/2023
1.0.64 2,553 10/18/2023
1.0.63 2,330 10/17/2023
1.0.62 2,837 10/16/2023
1.0.61 5,481 10/13/2023
1.0.60 3,149 10/12/2023
1.0.59 9,511 9/18/2023
1.0.58 287 9/18/2023
1.0.57 6,636 9/14/2023
1.0.56 6,059 8/31/2023
1.0.55 3,196 8/30/2023
1.0.54 2,627 8/29/2023
1.0.53 2,554 8/28/2023
1.0.52 5,044 8/25/2023
1.0.51 2,772 8/24/2023
1.0.50 6,728 8/21/2023
1.0.49 2,696 8/18/2023
1.0.48 2,516 8/17/2023
1.0.47 4,946 8/16/2023
1.0.46 7,823 8/10/2023
1.0.45 2,739 8/9/2023
1.0.44 4,748 8/8/2023
1.0.43 3,855 8/7/2023
1.0.42 4,090 8/4/2023
1.0.41 7,364 7/13/2023
1.0.40 5,030 7/11/2023
1.0.39 2,967 7/10/2023
1.0.38 3,854 7/7/2023
1.0.37 339 7/7/2023
1.0.36 10,516 6/30/2023
1.0.35 5,421 6/28/2023
1.0.34 5,702 6/27/2023
1.0.33 6,551 6/26/2023
1.0.32 3,811 6/23/2023
1.0.31 7,932 6/21/2023
1.0.30 8,123 6/15/2023
1.0.29 3,168 6/14/2023
1.0.28 8,710 6/9/2023
1.0.27 3,784 6/8/2023
1.0.26 4,743 6/7/2023
1.0.25 5,343 6/6/2023
1.0.24 361 6/6/2023
1.0.23 4,394 6/5/2023
1.0.22 15,026 5/30/2023
1.0.21 18,422 5/29/2023
1.0.20 6,271 5/26/2023
1.0.19 7,317 5/25/2023
1.0.18 7,722 5/24/2023
1.0.17 5,143 5/24/2023
1.0.16 1,450 5/23/2023
1.0.15 1,565 5/23/2023
1.0.12 2,711 5/22/2023
1.0.11 17,521 5/16/2023
1.0.10 14,286 4/20/2023
1.0.9 13,656 4/3/2023
1.0.8 1,206 4/3/2023
1.0.7 2,372 3/23/2023
1.0.5 735 3/13/2023
1.0.4 491 3/11/2023
1.0.3 414 3/11/2023
1.0.2 417 3/11/2023
1.0.1 464 3/11/2023