
动手
复制publicint AddWithSpinLock(ObjectModel.Request svarRequest)              {                  bool lockTaken = false;                  svarRequest.Ticket = Guid.NewGuid();                  var newRequestId = 0;                  try                  {                      _spinlock.Enter(ref lockTaken);                      _queue.Enqueue(svarRequest);                      while (null != _queue && _queue.Count > 0 && _queue.Peek().Ticket == svarRequest.Ticket)                      {                          // do something<br>                    _queue.Dequeue();                          return newRequestId;                      }                  }                  catch (Exception ex)                  {                      if (lockTaken) _spinlock.Exit(false);                      _queue.Dequeue();                      throw ex;                  }                  finally                  {                                     if (lockTaken) _spinlock.Exit(false);                  }                  return newRequestId;              }             1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.