Exemplo n.º 1
0
            public bool MoveNext()
            {
                while (true)
                {
                    if (result == null)
                    {
                        long readLoc = outputRows.GetReadLocation();

                        while (true)
                        {
                            if (outputRows.Read(readLoc, out result))
                            {
                                currentResult = -1;
                                break;
                            }
                            else
                            {
                                if (monitorExit)
                                {
                                    return(false);
                                }
                                else
                                {
                                    //no more rows to grab and we're here? might be time to exit.
                                    if (completionEvent.WaitOne(1))
                                    {
                                        monitorExit = true;
                                    }

                                    if (mp.WorkerThreadException != null)
                                    {
                                        throw mp.WorkerThreadException;
                                    }

                                    Thread.Sleep(0);
                                }
                            }
                        }
                    }

                    if (++currentResult > result.itemCount)
                    {
                        result = null;
                        continue;
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
Exemplo n.º 2
0
                public bool Read()
                {
                    while (true)
                    {
                        if (result == null)
                        {
                            long readLoc = bulkRows.GetReadLocation();

                            while (true)
                            {
                                if (bulkRows.Read(readLoc, out result))
                                {
                                    currentResult = -1;
                                    break;
                                }
                                else
                                {
                                    if (monitorExit)
                                    {
                                        //need to send back a message to the monitor thread
                                        return(false);
                                    }
                                    else
                                    {
                                        //no more rows to grab and we're here? might be time to exit.
                                        if (bulkCompletionEvent.WaitOne(1))
                                        {
                                            monitorExit = true;
                                        }

                                        //if the thread canceled flag is set, return true, so we can force an exception
                                        if (ThreadCanceled)
                                        {
                                            return(true);
                                        }
                                    }
                                }
                            }
                        }

                        if (++currentResult > result.itemCount)
                        {
                            result = null;
                            continue;
                        }
                        else
                        {
                            return(true);
                        }
                    }
                }