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 EnterUpgradeable() { var id = Guid.NewGuid(); idLock.EnterUpgradeable(id); Assert.IsTrue(idLock.UpgradeableLockTakenBy(id)); }