WikiFunctions.DBScanner.MainProcess.Process C# (CSharp) Method

Process() private method

private Process ( ) : void
return void
        private void Process()
        {
            string articleTitle = "";

            try
            {
                using (XmlTextReader reader = new XmlTextReader(stream))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;

                    if (From.Length > 0)
                    {
                        // move to start from article
                        while (Run && reader.Read())
                        {
                            if (reader.NodeType != XmlNodeType.Element)
                                continue;

                            if (reader.Name != "title")
                            {
                                reader.ReadToFollowing("page");
                                continue;
                            }

                            // reader.ReadToFollowing("title");
                            articleTitle = reader.ReadString();

                            if (From.Equals(articleTitle))
                                break;
                        }
                    }

                    while (Run)
                    {
                        ArticleInfo ai = ReadArticle(reader);
                        if (ai == null) break;
                        articleTitle = ai.Title;

                        // we must maintain a huge enough buffer to safeguard against fluctuations
                        // of page size
                        if (MultiThreaded && (PendingArticles.Count < ProcessorCount * 10))
                            PendingArticles.Add(ai);
                        else
                            ScanArticle(ai);
                    }

                    lock (ScanThread)
                    {
                        stream = null;
                    }

                    if (MultiThreaded)
                    {
                        while (PendingArticles.Count > 0)
                            Thread.Sleep(10);

                        Run = false;

                        foreach (Thread thr in SecondaryThreads)
                            thr.Join();
                    }
                }
            }
            catch (ThreadAbortException) { }
            catch (Exception ex)
            {
                if (Message)
                    //System.Windows.Forms.MessageBox.Show("Problem on " + articleTitle + "\r\n\r\n" + ex.Message);
                    ErrorHandler.HandleException(ex);
            }
            finally
            {
                if (Message)
                    Context.Post(SOPCstopped, articleTitle);
            }
        }