<PackageReference Include="System.Reactive" Version="4.3.1" />

AsyncLock

public sealed class AsyncLock : IDisposable
Asynchronous lock.
public AsyncLock()

public void Dispose()

Clears the work items in the queue and drops further work being queued.

public void Wait(Action action)

Queues the action for execution. If the caller acquires the lock and becomes the owner, the queue is processed. If the lock is already owned, the action is queued and will get processed by the owner.