//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCloseableScheduleWithFixedDelay() throws InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testCloseableScheduleWithFixedDelay() { CloseableScheduledExecutorService service = new CloseableScheduledExecutorService(executorService); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(QTY); CountDownLatch latch = new CountDownLatch(QTY); service.scheduleWithFixedDelay(() => { latch.countDown(); }, DELAY_MS, DELAY_MS, TimeUnit.MILLISECONDS); Assert.assertTrue(latch.@await((QTY * 2) * DELAY_MS, TimeUnit.MILLISECONDS)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCloseableScheduleWithFixedDelayAndAdditionalTasks() throws InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testCloseableScheduleWithFixedDelayAndAdditionalTasks() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger outerCounter = new java.util.concurrent.atomic.AtomicInteger(0); AtomicInteger outerCounter = new AtomicInteger(0); Runnable command = () => { outerCounter.incrementAndGet(); }; executorService.scheduleWithFixedDelay(command, DELAY_MS, DELAY_MS, TimeUnit.MILLISECONDS); CloseableScheduledExecutorService service = new CloseableScheduledExecutorService(executorService); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger innerCounter = new java.util.concurrent.atomic.AtomicInteger(0); AtomicInteger innerCounter = new AtomicInteger(0); service.scheduleWithFixedDelay(() => { innerCounter.incrementAndGet(); }, DELAY_MS, DELAY_MS, TimeUnit.MILLISECONDS); Thread.Sleep(DELAY_MS * 4); service.close(); Thread.Sleep(DELAY_MS * 2); int innerValue = innerCounter.get(); Assert.assertTrue(innerValue > 0); int value = outerCounter.get(); Thread.Sleep(DELAY_MS * 2); int newValue = outerCounter.get(); Assert.assertTrue(newValue > value); Assert.assertEquals(innerValue, innerCounter.get()); value = newValue; Thread.Sleep(DELAY_MS * 2); newValue = outerCounter.get(); Assert.assertTrue(newValue > value); Assert.assertEquals(innerValue, innerCounter.get()); }