Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

An awaitable semaphore class for the .NET's TPL library which can be used similar to the conventional `lock` block.

License

NotificationsYou must be signed in to change notification settings

rblt/async-lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An awaitable semaphore class for the .NET's TPL library which can be used similar to the conventionallock block.

Thelock block is mimicked by theusing(await ...)construct, so you can await entering the critical section in your asynchronous method.

Solution

Under the hood there areSemaphoreSlim instances are being used for synchronization, which is wrapped in a disposable class,see and build the source code with the given Visual Studio 2015 solution. The tests are using Moq and MSPEC.

Usage examples

You can create manyAsyncLock instances if needed:

privateAsyncLockLock=newAsyncLock();vartoken=newobject();using(awaitLock.AcquireAsync(token)){// critical section}

Or use the singleton version across your application:

using(awaitAsyncLock.CreateAsync(token)){// critical section}

Remarks

You can also use the synchronous version of both examples - without the 'Async' postfixes.

About

An awaitable semaphore class for the .NET's TPL library which can be used similar to the conventional `lock` block.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp