Esempio n. 1
0
            public bool MoveNext()
            {
                if (numTasks > 0)
                {
                    try
                    {
                        var awaitable = service.Take();
                        awaitable.Wait();
                        current = awaitable.Result;

                        return(true);
                    }
#if !NETSTANDARD1_6
                    catch (ThreadInterruptedException /*e*/)
                    {
                        //throw new ThreadInterruptedException(e.ToString(), e);
                        throw; // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
                    }
#endif
                    catch (Exception e)
                    {
                        // LUCENENET NOTE: We need to re-throw this as Exception to
                        // ensure it is not caught in the wrong place
                        throw new Exception(e.ToString(), e);
                    }
                    finally
                    {
                        --numTasks;
                    }
                }

                return(false);
            }
Esempio n. 2
0
            public bool MoveNext()
            {
                if (numTasks > 0)
                {
                    try
                    {
                        var awaitable = service.Take();
                        awaitable.Wait();
                        current = awaitable.Result;

                        return(true);
                    }
#if !NETSTANDARD1_6
                    catch (ThreadInterruptedException e)
                    {
                        throw new ThreadInterruptedException(e.ToString(), e);
                    }
#endif
                    catch (Exception e)
                    {
                        // LUCENENET NOTE: We need to re-throw this as Exception to
                        // ensure it is not caught in the wrong place
                        throw new Exception(e.ToString(), e);
                    }
                    finally
                    {
                        --numTasks;
                    }
                }

                return(false);
            }
Esempio n. 3
0
            /*public override T Next()
             * {
             * if (!this.HasNext())
             * {
             *  throw new NoSuchElementException("next() is called but hasNext() returned false");
             * }
             * try
             * {
             *  return Service.Take().Get();
             * }
             * catch (ThreadInterruptedException e)
             * {
             *  throw new ThreadInterruptedException(e);
             * }
             * catch (ExecutionException e)
             * {
             *  throw new Exception(e);
             * }
             * finally
             * {
             *  --NumTasks;
             * }
             * }*/

            public bool MoveNext()
            {
                if (NumTasks > 0)
                {
                    try
                    {
                        current = Service.Take().Result;
                    }
                    finally
                    {
                        --NumTasks;
                    }
                }

                return(false);
            }