Soenneker.Utils.AsyncSingleton 2.1.387

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

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

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.428 0 11/9/2024
2.1.427 0 11/9/2024
2.1.426 7 11/8/2024
2.1.425 48 11/8/2024
2.1.424 118 11/8/2024
2.1.423 264 11/8/2024
2.1.422 440 11/8/2024
2.1.421 1,260 11/8/2024
2.1.420 9,205 11/1/2024
2.1.419 8,219 10/29/2024
2.1.418 3,190 10/29/2024
2.1.417 4,355 10/29/2024
2.1.416 8,159 10/28/2024
2.1.415 8,071 10/26/2024
2.1.414 7,433 10/22/2024
2.1.413 2,918 10/22/2024
2.1.412 1,636 10/22/2024
2.1.411 8,987 10/17/2024
2.1.410 8,022 10/15/2024
2.1.409 1,457 10/14/2024
2.1.408 8,308 10/11/2024
2.1.407 2,262 10/11/2024
2.1.406 1,477 10/11/2024
2.1.404 12,252 10/8/2024
2.1.403 5,041 10/8/2024
2.1.402 15,061 10/3/2024
2.1.401 1,065 10/3/2024
2.1.400 2,520 10/3/2024
2.1.399 9,783 10/2/2024
2.1.398 3,230 10/2/2024
2.1.397 10,192 10/1/2024
2.1.396 898 10/1/2024
2.1.395 5,041 9/30/2024
2.1.394 7,857 9/29/2024
2.1.393 2,535 9/29/2024
2.1.392 2,435 9/29/2024
2.1.391 6,728 9/27/2024
2.1.390 4,707 9/27/2024
2.1.389 141 9/27/2024
2.1.388 718 9/27/2024
2.1.387 1,738 9/27/2024
2.1.386 85 9/27/2024
2.1.385 10,447 9/26/2024
2.1.384 9,156 9/26/2024
2.1.383 3,986 9/26/2024
2.1.382 11,514 9/23/2024
2.1.381 2,862 9/23/2024
2.1.380 4,964 9/23/2024
2.1.379 4,935 9/23/2024
2.1.378 3,729 9/23/2024
2.1.377 740 9/23/2024
2.1.376 1,858 9/23/2024
2.1.375 77 9/23/2024
2.1.374 13,554 9/17/2024
2.1.373 652 9/17/2024
2.1.372 2,718 9/17/2024
2.1.371 2,716 9/17/2024
2.1.370 3,099 9/17/2024
2.1.369 4,221 9/17/2024
2.1.368 4,711 9/17/2024
2.1.367 15,333 9/16/2024
2.1.366 7,987 9/12/2024
2.1.365 3,026 9/11/2024
2.1.363 8,882 9/11/2024
2.1.362 17,150 9/10/2024
2.1.361 705 9/10/2024
2.1.360 1,025 9/10/2024
2.1.359 903 9/10/2024
2.1.358 3,650 9/9/2024
2.1.357 1,499 9/9/2024
2.1.356 6,259 9/9/2024
2.1.355 1,728 9/9/2024
2.1.354 6,988 9/9/2024
2.1.353 13,452 9/7/2024
2.1.352 9,898 9/6/2024
2.1.351 5,117 9/5/2024
2.1.350 5,138 9/5/2024
2.1.349 539 9/5/2024
2.1.348 123 9/5/2024
2.1.347 9,023 9/5/2024
2.1.346 999 9/4/2024
2.1.345 13,571 9/3/2024
2.1.344 6,098 9/3/2024
2.1.343 4,512 9/3/2024
2.1.342 8,652 8/29/2024
2.1.341 7,234 8/26/2024
2.1.340 7,659 8/21/2024
2.1.339 2,804 8/21/2024
2.1.338 1,631 8/20/2024
2.1.337 5,787 8/20/2024
2.1.336 101 8/20/2024
2.1.335 103 8/20/2024
2.1.334 9,751 8/19/2024
2.1.333 9,455 8/15/2024
2.1.332 9,454 8/13/2024
2.1.331 7,911 8/6/2024
2.1.330 4,322 8/6/2024
2.1.329 6,541 8/1/2024
2.1.328 1,337 8/1/2024
2.1.327 605 8/1/2024
2.1.326 9,457 7/25/2024
2.1.325 1,960 7/25/2024
2.1.324 1,693 7/25/2024
2.1.323 253 7/24/2024
2.1.322 703 7/24/2024
2.1.321 328 7/24/2024
2.1.320 8,934 7/20/2024
2.1.319 11,708 7/14/2024
2.1.318 4,440 7/14/2024
2.1.317 6,769 7/10/2024
2.1.316 2,939 7/10/2024
2.1.315 2,729 7/10/2024
2.1.314 1,580 7/10/2024
2.1.313 994 7/10/2024
2.1.312 307 7/10/2024
2.1.311 2,590 7/10/2024
2.1.310 1,331 7/9/2024
2.1.308 2,745 7/9/2024
2.1.307 83 7/9/2024
2.1.306 2,919 7/9/2024
2.1.305 6,773 7/9/2024
2.1.304 5,667 7/9/2024
2.1.303 2,718 7/9/2024
2.1.302 81 7/9/2024
2.1.301 3,389 7/9/2024
2.1.300 6,097 7/8/2024
2.1.299 351 7/8/2024
2.1.298 84 7/8/2024
2.1.297 92 7/8/2024
2.1.296 8,372 7/8/2024
2.1.295 1,620 7/7/2024
2.1.294 5,061 7/7/2024
2.1.293 106 7/7/2024
2.1.292 1,427 7/7/2024
2.1.291 3,073 7/7/2024
2.1.290 10,234 7/3/2024
2.1.289 3,270 7/3/2024
2.1.288 2,915 7/3/2024
2.1.287 817 7/3/2024
2.1.286 5,638 7/2/2024
2.1.283 3,516 6/30/2024
2.1.282 2,352 6/28/2024
2.1.281 227 6/28/2024
2.1.279 7,633 6/22/2024
2.1.278 8,577 6/15/2024
2.1.277 1,154 6/15/2024
2.1.276 6,729 6/14/2024
2.1.275 10,711 6/1/2024
2.1.274 1,714 6/1/2024
2.1.273 1,085 6/1/2024
2.1.272 9,377 5/31/2024
2.1.271 5,855 5/29/2024
2.1.270 6,684 5/28/2024
2.1.269 3,754 5/27/2024
2.1.268 6,944 5/26/2024
2.1.267 6,868 5/26/2024
2.1.266 301 5/26/2024
2.1.265 2,504 5/25/2024
2.1.264 1,805 5/25/2024
2.1.263 1,655 5/25/2024
2.1.262 98 5/25/2024
2.1.261 1,334 5/25/2024
2.1.260 96 5/25/2024
2.1.259 4,860 5/25/2024
2.1.258 90 5/25/2024
2.1.257 8,680 5/23/2024
2.1.256 3,431 5/23/2024
2.1.255 2,445 5/22/2024
2.1.254 1,850 5/22/2024
2.1.253 739 5/22/2024
2.1.252 90 5/22/2024
2.1.251 88 5/22/2024
2.1.250 3,600 5/22/2024
2.1.249 9,235 5/18/2024
2.1.248 1,933 5/17/2024
2.1.247 3,316 5/17/2024
2.1.246 5,191 5/16/2024
2.1.245 1,334 5/15/2024
2.1.244 3,774 5/15/2024
2.1.243 7,744 5/12/2024
2.1.242 4,215 5/3/2024
2.1.241 4,723 4/29/2024
2.1.240 2,696 4/29/2024
2.1.239 5,204 4/28/2024
2.1.238 836 4/28/2024
2.1.237 956 4/28/2024
2.1.236 3,908 4/28/2024
2.1.235 537 4/28/2024
2.1.234 5,193 4/28/2024
2.1.233 1,088 4/28/2024
2.1.232 4,869 4/27/2024
2.1.231 96 4/27/2024
2.1.230 9,826 4/19/2024
2.1.229 6,088 4/18/2024
2.1.228 6,364 4/12/2024
2.1.227 1,011 4/12/2024
2.1.226 1,622 4/12/2024
2.1.225 1,355 4/12/2024
2.1.224 945 4/12/2024
2.1.223 1,365 4/12/2024
2.1.222 509 4/12/2024
2.1.221 102 4/12/2024
2.1.220 3,568 4/10/2024
2.1.219 14,147 4/10/2024
2.1.218 664 4/10/2024
2.1.217 7,585 4/2/2024
2.1.216 1,321 4/1/2024
2.1.215 7,298 3/29/2024
2.1.214 5,313 3/25/2024
2.1.213 600 3/25/2024
2.1.212 7,396 3/20/2024
2.1.211 5,022 3/19/2024
2.1.210 3,026 3/19/2024
2.1.209 3,345 3/18/2024
2.1.208 7,344 3/15/2024
2.1.207 4,992 3/13/2024
2.1.206 1,902 3/13/2024
2.1.205 2,480 3/13/2024
2.1.204 149 3/13/2024
2.1.203 130 3/13/2024
2.1.202 1,639 3/13/2024
2.1.201 145 3/13/2024
2.1.200 3,589 3/12/2024
2.1.199 4,615 3/12/2024
2.1.198 6,020 3/11/2024
2.1.197 4,176 3/11/2024
2.1.196 4,482 3/10/2024
2.1.195 5,784 3/8/2024
2.1.194 520 3/8/2024
2.1.193 4,180 3/8/2024
2.1.192 5,378 3/6/2024
2.1.191 5,370 3/4/2024
2.1.190 3,032 3/4/2024
2.1.189 6,083 3/2/2024
2.1.188 1,542 3/2/2024
2.1.187 1,925 3/2/2024
2.1.186 1,079 3/2/2024
2.1.185 748 3/2/2024
2.1.184 4,065 2/29/2024
2.1.183 1,324 2/29/2024
2.1.182 2,043 2/29/2024
2.1.181 3,939 2/26/2024
2.1.180 15,248 2/25/2024
2.1.179 1,808 2/25/2024
2.1.178 6,008 2/23/2024
2.1.177 5,824 2/22/2024
2.1.176 1,616 2/22/2024
2.1.175 1,951 2/21/2024
2.1.174 3,164 2/21/2024
2.1.173 2,842 2/21/2024
2.1.172 3,583 2/21/2024
2.1.171 1,536 2/21/2024
2.1.170 339 2/21/2024
2.1.169 3,291 2/21/2024
2.1.168 1,012 2/20/2024
2.1.167 189 2/20/2024
2.1.166 196 2/20/2024
2.1.165 4,387 2/20/2024
2.1.164 3,303 2/20/2024
2.1.163 3,180 2/20/2024
2.1.162 6,682 2/19/2024
2.1.161 5,328 2/17/2024
2.1.160 2,210 2/17/2024
2.1.159 1,583 2/16/2024
2.1.158 1,147 2/16/2024
2.1.157 1,937 2/16/2024
2.1.156 2,989 2/16/2024
2.1.155 3,440 2/16/2024
2.1.154 227 2/16/2024
2.1.153 1,696 2/16/2024
2.1.152 229 2/16/2024
2.1.151 224 2/16/2024
2.1.150 5,915 2/14/2024
2.1.149 2,503 2/13/2024
2.1.148 3,010 2/13/2024
2.1.147 3,639 2/13/2024
2.1.146 3,493 2/13/2024
2.1.145 4,829 2/12/2024
2.1.144 751 2/11/2024
2.1.143 5,253 2/11/2024
2.1.142 2,960 2/11/2024
2.1.141 6,136 2/10/2024
2.1.140 755 2/9/2024
2.1.139 5,602 2/9/2024
2.1.138 3,610 2/9/2024
2.1.137 945 2/8/2024
2.1.136 4,502 2/8/2024
2.1.135 1,829 2/8/2024
2.1.134 10,445 2/8/2024
2.1.133 300 2/8/2024
2.1.132 229 2/8/2024
2.1.131 5,141 2/7/2024
2.1.130 2,044 2/7/2024
2.1.129 3,510 2/7/2024
2.1.128 1,136 2/7/2024
2.1.127 999 2/6/2024
2.1.126 2,798 2/6/2024
2.1.125 269 2/6/2024
2.1.124 7,402 2/5/2024
2.1.123 4,828 2/4/2024
2.1.122 5,144 2/2/2024
2.1.121 6,118 1/31/2024
2.1.120 6,011 1/29/2024
2.1.119 3,622 1/29/2024
2.1.118 2,436 1/29/2024
2.1.117 3,881 1/28/2024
2.1.116 5,152 1/28/2024
2.1.115 2,929 1/28/2024
2.1.114 1,708 1/28/2024
2.1.113 2,329 1/27/2024
2.1.112 2,055 1/27/2024
2.1.111 5,367 1/27/2024
2.1.110 2,700 1/27/2024
2.1.109 6,438 1/27/2024
2.1.108 1,664 1/26/2024
2.1.107 2,106 1/26/2024
2.1.106 2,734 1/26/2024
2.1.105 4,959 1/26/2024
2.1.104 2,357 1/26/2024
2.1.103 1,303 1/26/2024
2.1.102 4,417 1/25/2024
2.1.101 3,510 1/25/2024
2.1.100 1,697 1/25/2024
2.1.99 5,682 1/25/2024
2.1.98 5,471 1/19/2024
2.1.97 5,673 1/15/2024
2.1.96 2,585 1/15/2024
2.1.95 2,028 1/15/2024
2.1.94 5,150 1/15/2024
2.1.93 5,298 1/15/2024
2.1.92 5,126 1/14/2024
2.1.91 6,288 1/13/2024
2.1.90 5,261 1/12/2024
2.1.89 5,157 1/11/2024
2.1.88 7,140 1/7/2024
2.1.87 5,686 1/5/2024
2.1.86 2,539 1/5/2024
2.1.85 3,233 1/5/2024
2.1.84 6,108 1/3/2024
2.1.83 3,724 1/1/2024
2.1.82 5,083 12/28/2023
2.1.81 2,047 12/28/2023
2.1.80 2,057 12/28/2023
2.1.79 4,553 12/27/2023
2.1.78 2,132 12/27/2023
2.1.77 285 12/27/2023
2.1.76 8,748 12/25/2023
2.1.75 4,795 12/25/2023
2.1.74 2,432 12/25/2023
2.1.73 685 12/25/2023
2.1.72 311 12/25/2023
2.1.71 6,894 12/24/2023
2.1.70 5,381 12/23/2023
2.1.69 2,878 12/23/2023
2.1.68 1,702 12/23/2023
2.1.67 3,872 12/23/2023
2.1.66 283 12/23/2023
2.1.65 8,140 12/19/2023
2.1.64 2,234 12/19/2023
2.1.63 5,500 12/12/2023
2.1.62 456 12/12/2023
2.1.61 2,709 12/11/2023
2.1.60 2,203 12/11/2023
2.1.59 1,223 12/11/2023
2.1.58 1,655 12/11/2023
2.1.57 816 12/10/2023
2.1.56 791 12/10/2023
2.1.55 1,818 12/10/2023
2.1.54 1,123 12/10/2023
2.1.53 8,185 12/10/2023
2.1.52 1,856 12/9/2023
2.1.51 1,042 12/9/2023
2.1.50 1,610 12/9/2023
2.1.49 2,484 12/9/2023
2.1.48 256 12/9/2023
2.1.47 1,266 12/9/2023
2.1.46 330 12/9/2023
2.1.45 2,861 12/9/2023
2.1.44 290 12/9/2023
2.1.43 4,516 12/9/2023
2.1.42 6,763 12/6/2023
2.1.41 1,237 12/6/2023
2.1.40 1,769 12/6/2023
2.1.39 3,986 12/5/2023
2.1.38 2,005 12/5/2023
2.1.37 1,126 12/5/2023
2.1.36 2,863 12/5/2023
2.1.35 285 12/5/2023
2.1.34 2,431 12/5/2023
2.1.33 293 12/5/2023
2.1.32 1,602 12/4/2023
2.1.31 1,531 12/4/2023
2.1.30 320 12/4/2023
2.1.29 8,829 12/4/2023
2.1.28 2,902 11/27/2023
2.1.27 1,354 11/26/2023
2.1.26 3,402 11/23/2023
2.1.25 2,938 11/23/2023
2.1.24 3,583 11/23/2023
2.1.23 294 11/23/2023
2.1.22 7,013 11/20/2023
2.1.21 3,388 11/20/2023
2.1.20 5,484 11/19/2023
2.1.19 3,008 11/19/2023
2.1.18 4,151 11/19/2023
2.1.17 1,110 11/18/2023
2.1.16 5,394 11/18/2023
2.1.15 1,303 11/18/2023
2.1.14 3,424 11/18/2023
2.1.13 749 11/18/2023
2.1.12 3,557 11/17/2023
2.1.11 2,931 11/17/2023
2.1.10 2,174 11/17/2023
2.1.9 400 11/17/2023
2.1.8 3,466 11/17/2023
2.1.7 2,002 11/17/2023
2.1.6 2,524 11/17/2023
2.1.5 1,722 11/17/2023
2.1.4 581 11/17/2023
2.1.3 3,277 11/16/2023
2.0.78 1,121 11/15/2023
2.0.77 310 11/15/2023
2.0.76 2,935 11/15/2023
2.0.2 316 11/16/2023
2.0.1 278 11/16/2023
1.0.75 4,223 11/13/2023
1.0.74 6,078 11/10/2023
1.0.73 4,781 11/9/2023
1.0.72 3,248 11/8/2023
1.0.71 4,986 11/7/2023
1.0.70 2,481 11/6/2023
1.0.69 3,105 11/3/2023
1.0.68 5,610 11/2/2023
1.0.67 3,421 11/1/2023
1.0.66 10,905 10/26/2023
1.0.65 6,685 10/19/2023
1.0.64 2,896 10/18/2023
1.0.63 2,804 10/17/2023
1.0.62 3,393 10/16/2023
1.0.61 6,190 10/13/2023
1.0.60 3,627 10/12/2023
1.0.59 11,386 9/18/2023
1.0.58 300 9/18/2023
1.0.57 7,671 9/14/2023
1.0.56 7,161 8/31/2023
1.0.55 3,632 8/30/2023
1.0.54 3,107 8/29/2023
1.0.53 3,026 8/28/2023
1.0.52 5,788 8/25/2023
1.0.51 3,249 8/24/2023
1.0.50 7,894 8/21/2023
1.0.49 3,207 8/18/2023
1.0.48 2,980 8/17/2023
1.0.47 5,492 8/16/2023
1.0.46 9,048 8/10/2023
1.0.45 3,153 8/9/2023
1.0.44 5,277 8/8/2023
1.0.43 4,456 8/7/2023
1.0.42 4,646 8/4/2023
1.0.41 8,571 7/13/2023
1.0.40 5,705 7/11/2023
1.0.39 3,464 7/10/2023
1.0.38 4,346 7/7/2023
1.0.37 356 7/7/2023
1.0.36 11,995 6/30/2023
1.0.35 6,175 6/28/2023
1.0.34 6,310 6/27/2023
1.0.33 7,315 6/26/2023
1.0.32 4,353 6/23/2023
1.0.31 8,852 6/21/2023
1.0.30 9,232 6/15/2023
1.0.29 3,644 6/14/2023
1.0.28 9,836 6/9/2023
1.0.27 4,275 6/8/2023
1.0.26 5,230 6/7/2023
1.0.25 5,886 6/6/2023
1.0.24 382 6/6/2023
1.0.23 4,926 6/5/2023
1.0.22 17,007 5/30/2023
1.0.21 19,856 5/29/2023
1.0.20 6,861 5/26/2023
1.0.19 7,993 5/25/2023
1.0.18 8,349 5/24/2023
1.0.17 5,655 5/24/2023
1.0.16 1,684 5/23/2023
1.0.15 1,664 5/23/2023
1.0.12 3,096 5/22/2023
1.0.11 19,260 5/16/2023
1.0.10 15,861 4/20/2023
1.0.9 15,183 4/3/2023
1.0.8 1,266 4/3/2023
1.0.7 2,509 3/23/2023
1.0.5 766 3/13/2023
1.0.4 524 3/11/2023
1.0.3 430 3/11/2023
1.0.2 434 3/11/2023
1.0.1 488 3/11/2023