private VerificationResult WaitForMoreUserActions()
        {
            m_verifierRequestType = VerifierRequestTypes.RequestUserAction;

            m_eventUserInputRequest.Set();
            m_eventUserInputAvailable.WaitOne();

            if (m_cancelationPending)
            {
                return(null);
            }

            string tempSelSug = SelectedSuggestion;

            return(new VerificationResult
            {
                SelectedSuggestion = tempSelSug,
                UserAction = LastUserAction,
                ViewerControlArg = m_viewerControlArg
            });
        }
        private void VerifierThreadCallBack()
        {
            LastUserAction = UserSelectedActions.None;
            IEnumerable <RangeWrapper> parEnumerable = RangeWrapper.ReadParagraphsStartingFromCursor(m_verifier.Document);

            try
            {
                // Check if revisions are visible, if so make them invisible and turn them back on in the end
                m_isRevisionsEnabled = DocumentUtils.IsRevisionsEnabled(m_verifier.Document);
                if (m_isRevisionsEnabled)
                {
                    DocumentUtils.ChangeShowingRevisions(m_verifier.Document, false);
                }

                while (!m_cancelationPending)
                {
                    foreach (RangeWrapper par in parEnumerable)
                    {
                        SendParagraphForVerification(par);

                        if (m_cancelationPending)
                        {
                            break;
                        }

                        if (m_cancelationPending || LastUserAction == UserSelectedActions.Resume)
                        {
                            break;
                        }
                    } // end of foreach par

                    // if resume was pressed without been cancelled, then restart from the beginning
                    if (!m_cancelationPending && LastUserAction == UserSelectedActions.Resume)
                    {
                        parEnumerable  = RangeWrapper.ReadParagraphsStartingFromCursor(m_verifier.Document);
                        LastUserAction = UserSelectedActions.None;
                    }
                    // otherwise it means that we actually reached the end of the text
                    else if (!m_cancelationPending)
                    {
                        m_verifierRequestType = VerifierRequestTypes.RequestEndOfLoop;
                        m_eventUserInputRequest.Set();
                        m_eventUserInputAvailable.WaitOne();

                        if (!m_cancelationPending)
                        {
                            // make it read from the beginning of the document
                            parEnumerable  = RangeWrapper.ReadParagraphs(m_verifier.Document);
                            LastUserAction = UserSelectedActions.None;
                            HideResumeButton();
                            GoIdle();
                        }
                    }
                } // end of while
            }
            finally
            {
                // Check if revisions are visible, if so make them invisible and turn them back on in the end
                if (m_isRevisionsEnabled && !m_isDocumentClosed)
                {
                    DocumentUtils.ChangeShowingRevisions(m_verifier.Document, true);
                }
                //m_eventVerifierThreadStoped.Set();
            }
        }