Is there now a .NET SDK equivalent to AsyncEx's AsyncLock?

104 views Asked by At

I was reading this question and at the time of writing, there were two async locking primitives that were widely used in C#; AsyncLock from the AsyncEx library, and Scott Hanselman's AsyncLock (based on Stephen Toub's AsyncLock). Neither are officially supported by Microsoft, and for something as fundamental as synchronization primitives I'd really prefer to use a lock that's actually in the .NET SDK/framework and which is official.

Has Microsoft yet introduced anything official to this extent? ie. an async equivalent to a lock block? If not, are there any plans to do so? It seems like a rather large oversight. I know you can use SemaphoreSlim to achieve an async mutex, but it's still not a proper locking class.

Proper locking class: a class that provides an IDisposable releaser, so that it can be used with the using statement.

1

There are 1 answers

0
Theodor Zoulias On BEST ANSWER

Has Microsoft yet introduced anything official to this extent?

No. Currently there is a movement towards a new Lock type, that is intended as an alternative for the lock statement. AFAIK there is nothing going on in the C# language or the .NET runtime, about an await lock statement or an AsyncLock type.