//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException public virtual List <Future <T> > invokeAll <T, T1>(Collection <T1> tasks, long timeout, TimeUnit unit) where T1 : Callable <T> { if (tasks == null) { throw new NullPointerException(); } long nanos = unit.ToNanos(timeout); List <Future <T> > futures = new List <Future <T> >(tasks.Size()); bool done = false; try { foreach (Callable <T> t in tasks) { futures.Add(NewTaskFor(t)); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long deadline = System.nanoTime() + nanos; long deadline = System.nanoTime() + nanos; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int size = futures.size(); int size = futures.Size(); // Interleave time checks and calls to execute in case // executor doesn't have any/much parallelism. for (int i = 0; i < size; i++) { Execute((Runnable)futures.Get(i)); nanos = deadline - System.nanoTime(); if (nanos <= 0L) { return(futures); } } for (int i = 0; i < size; i++) { Future <T> f = futures.Get(i); if (!f.Done) { if (nanos <= 0L) { return(futures); } try { f.Get(nanos, TimeUnit.NANOSECONDS); } catch (CancellationException) { } catch (ExecutionException) { } catch (TimeoutException) { return(futures); } nanos = deadline - System.nanoTime(); } } done = true; return(futures); } finally { if (!done) { for (int i = 0, size = futures.Size(); i < size; i++) { futures.Get(i).Cancel(true); } } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException public virtual T invokeAny <T, T1>(Collection <T1> tasks, long timeout, TimeUnit unit) where T1 : Callable <T> { return(DoInvokeAny(tasks, true, unit.ToNanos(timeout))); }