public void Dispose()
 {
     if (locker != null)
     {
         // it is important that these never throw exceptions, they shouldn't ever
         // because Interlocked should never throw
         locker.ReleaseReadLock();
         if (write)
         {
             locker.ReleaseWriteLock();
         }
         locker = null;
     }
 }