public bool cancel()
            {
                IFuture <object> value;

                _executorService.futures.TryRemove(_scheduledFuture, out value);
                return(_scheduledFuture.cancel());
            }
Ejemplo n.º 2
0
        public void testListeningCallable()
        {
            CloseableExecutorService service    = new CloseableExecutorService(executorService);
            CountdownEvent           startLatch = new CountdownEvent(QTY);
            List <IFuture <object> > futures    = new List <IFuture <object> >();

            for (int i = 0; i < QTY; ++i)
            {
                IFuture <object> future = submitJoinRunnable(service, startLatch);
                futures.Add(future);
            }

            Assert.True(startLatch.Wait(TimeSpan.FromSeconds(15)));
            foreach (IFuture <object> future in futures)
            {
                future.cancel();
            }
            Thread.Sleep(TimeSpan.FromSeconds(5));
            Assert.AreEqual(0, service.size());
        }