public void Test_InMonitor_WithDoubleEntriesSingleTask_ExceptionInOuter() { const int numberOfIterations = 200; int cnt = 0; var monitor = new SpinMonitor(); for (int i = 0; i < numberOfIterations; i++) { try { monitor.InMonitor(() => { cnt++; monitor.InMonitor(() => { cnt++; }); throw new ApplicationException(); }); } catch (ApplicationException) { } } Assert.AreEqual(numberOfIterations * 2, cnt); }
public void Test_InMonitor_WithDoubleEntriesMultipleTasks_ExceptionInOuter() { const int numberOfIterations = 200; int cnt = 0; var monitor = new SpinMonitor(); Parallel.For(0, numberOfIterations, i => { try { monitor.InMonitor(() => { cnt++; monitor.InMonitor(() => { cnt++; }); throw new ApplicationException(); }); } catch (ApplicationException) { } }); Assert.AreEqual(numberOfIterations * 2, cnt); }
public void Test_InMonitor_WithDoubleEntriesMultipleTasks() { const int numberOfIterations = 200; int cnt = 0; var monitor = new SpinMonitor(); Parallel.For(0, numberOfIterations, i => monitor.InMonitor(() => { cnt++; monitor.InMonitor(() => { cnt++; }); })); Assert.AreEqual(numberOfIterations * 2, cnt); }
public void Test_InMonitor_WithDoubleEntriesSingleTask() { const int numberOfIterations = 200; int cnt = 0; var monitor = new SpinMonitor(); for (int i = 0; i < numberOfIterations; i++) { monitor.InMonitor(() => { cnt++; monitor.InMonitor(() => { cnt++; }); }); } Assert.AreEqual(numberOfIterations * 2, cnt); }