private void UpgradeableWorker() { try { startEvent.Wait(); for (int j = 0; j < iterations; j++) { if (errorToken.Token.IsCancellationRequested) { return; } Guid id = Guid.NewGuid(); idLock.EnterUpgradeable(id); SetProtectedValue(); idLock.EnterExclusive(id); IncrementProtectedValue(); idLock.ExitExclusive(id); SetProtectedValue(); idLock.ExitUpgradeable(id); } } catch (Exception e) { error = e; errorToken.Cancel(); } }
public void ExitUpgradeable() { var id = Guid.NewGuid(); idLock.EnterUpgradeable(id); idLock.ExitUpgradeable(id); Assert.IsFalse(idLock.UpgradeableLockTakenBy(id)); }