Looking for a framework class that allows one writer and rejects other writers
<p>I am aware of the <a href="https://msdn.microsoft.com/en-us/library/system.threading.readerwriterlock(v=vs.110).aspx" rel="nofollow"><code>ReaderWriterLock</code></a> and <a href="https://msdn.microsoft.com/en-us/library/system.threading.readerwriterlockslim(v=vs.110).aspx" rel="nofollow"><code>ReaderWriterLockSlim</code></a> classes and I'm looking for something similar and I hope that there's a .NET framework class already, so I don't need to bother implementing my own.</p>

<p>Here's what I'm looking for:</p>

<ul>
<li>one writer can enter the "lock"</li>
<li>one more writer can wait in a queue if the "lock" is owned</li>
<li>any more writers just return or get an exception that the operation is currently not possible</li>
</ul>

<p>Does such a class exist in the .NET framework?</p>

<p>What I want to achieve: there are incoming triggers at a very high rate. On each trigger I want to save state information (bullet point 1). The data is not too important, so I don't really care about some items getting lost (bullet point 3).</p>

<p>However, I want to ensure that I capture at least one state which was triggered while I was saving data, because it could contain an important change. That makes up bullet point 2. I know that there's no guarantee that I will be able to capture that state change, because it could have been changed forth and back multiple times. That's acceptable. At least I want to try...</p>