mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 14:19:29 +00:00
Expose SemaphoreSlim.Acquire with CancellationToken
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<RootNamespace>System</RootNamespace>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<Version>1.6.11</Version>
|
||||
<Version>1.6.12</Version>
|
||||
<Authors>Alexandru Macocian</Authors>
|
||||
<RepositoryUrl>https://github.com/AlexMacocian/SystemExtensions</RepositoryUrl>
|
||||
<Description>Extensions for the System namespace</Description>
|
||||
|
||||
@@ -8,4 +8,9 @@ public static class SemaphoreSlimExtensions
|
||||
{
|
||||
return await SemaphoreSlimContext.Create(semaphore);
|
||||
}
|
||||
|
||||
public static async Task<SemaphoreSlimContext> Acquire(this SemaphoreSlim semaphore, CancellationToken cancellationToken)
|
||||
{
|
||||
return await SemaphoreSlimContext.Create(semaphore, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<RootNamespace>System</RootNamespace>
|
||||
<Version>1.6.11</Version>
|
||||
<Version>1.6.12</Version>
|
||||
<Authors>Alexandru Macocian</Authors>
|
||||
<RepositoryUrl>https://github.com/AlexMacocian/SystemExtensions</RepositoryUrl>
|
||||
<Description>Extensions for the System namespace</Description>
|
||||
|
||||
@@ -21,4 +21,10 @@ public readonly struct SemaphoreSlimContext : IDisposable
|
||||
await semaphore.ThrowIfNull(nameof(semaphore)).WaitAsync();
|
||||
return new SemaphoreSlimContext(semaphore);
|
||||
}
|
||||
|
||||
public static async Task<SemaphoreSlimContext> Create(SemaphoreSlim semaphore, CancellationToken cancellationToken)
|
||||
{
|
||||
await semaphore.ThrowIfNull(nameof(semaphore)).WaitAsync(cancellationToken);
|
||||
return new SemaphoreSlimContext(semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user