1 namespace System.Web.Mvc.Async {
3 using System.Threading;
5 // used to synchronize access to a single-use consumable resource
6 internal sealed class SingleEntryGate {
8 private const int NOT_ENTERED = 0;
9 private const int ENTERED = 1;
13 // returns true if this is the first call to TryEnter(), false otherwise
14 public bool TryEnter() {
15 int oldStatus = Interlocked.Exchange(ref _status, ENTERED);
16 return (oldStatus == NOT_ENTERED);