Example #1
0
    private void Run()
    {
      while (!this.shouldStop)
      {
        this.newListEvent.WaitOne();
        this.newListEvent.Reset();
        if (this.shouldStop)
        {
          break;
        }
        lock (this.highlightDict)
        {
          this.highlightDict.Clear();
        }
        int lineCount = this.callback.GetLineCount();

        lock (this.listLock)
        {
          foreach (HilightEntry searchEntry in this.highlightEntryList)
          {
            if (this.shouldStop || newList)
            {
              break;
            }
            if (searchEntry.FilterParams != null)
            {
              int startLine = 0;
              Filter filter = new Filter(callback);
              bool doFilter = true;
              while (doFilter && !newList)
              {
                //Thread.Sleep(5);
                doFilter = filter.DoFilter(searchEntry.FilterParams, startLine, FILTER_COUNT);
                IList<int> resultLines = filter.FilterResultLines;
                bool hasChanged = false;
                foreach (int line in resultLines)
                {
                  hasChanged = true;
                  if (this.shouldStop)
                  {
                    break;
                  }
                  HighlightResults results;
                  if (!this.highlightDict.ContainsKey(line))
                  {
                    lock (this.highlightDict)
                    {
                      this.highlightDict[line] = results = new HighlightResults();
                    }
                  }
                  else
                  {
                    results = this.highlightDict[line];
                  }
                  lock (results)
                  {
                    results.HighlightEntryList.Add(searchEntry);
                  }
                }
                if (hasChanged)
                {
                  OnHighlightDone(new HighlightEventArgs(startLine, FILTER_COUNT));
                }
                startLine += FILTER_COUNT;
              }
            }
          }
        }
      }
    }
Example #2
0
        private void Run()
        {
            while (!this.shouldStop)
            {
                this.newListEvent.WaitOne();
                this.newListEvent.Reset();
                if (this.shouldStop)
                {
                    break;
                }
                lock (this.highlightDict)
                {
                    this.highlightDict.Clear();
                }
                int lineCount = this.callback.GetLineCount();

                lock (this.listLock)
                {
                    foreach (HilightEntry searchEntry in this.highlightEntryList)
                    {
                        if (this.shouldStop || newList)
                        {
                            break;
                        }
                        if (searchEntry.FilterParams != null)
                        {
                            int    startLine = 0;
                            Filter filter    = new Filter(callback);
                            bool   doFilter  = true;
                            while (doFilter && !newList)
                            {
                                //Thread.Sleep(5);
                                doFilter = filter.DoFilter(searchEntry.FilterParams, startLine, FILTER_COUNT);
                                IList <int> resultLines = filter.FilterResultLines;
                                bool        hasChanged  = false;
                                foreach (int line in resultLines)
                                {
                                    hasChanged = true;
                                    if (this.shouldStop)
                                    {
                                        break;
                                    }
                                    HighlightResults results;
                                    if (!this.highlightDict.ContainsKey(line))
                                    {
                                        lock (this.highlightDict)
                                        {
                                            this.highlightDict[line] = results = new HighlightResults();
                                        }
                                    }
                                    else
                                    {
                                        results = this.highlightDict[line];
                                    }
                                    lock (results)
                                    {
                                        results.HighlightEntryList.Add(searchEntry);
                                    }
                                }
                                if (hasChanged)
                                {
                                    OnHighlightDone(new HighlightEventArgs(startLine, FILTER_COUNT));
                                }
                                startLine += FILTER_COUNT;
                            }
                        }
                    }
                }
            }
        }