Ejemplo n.º 1
0
        private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
        {
            Logger.logInfo("Started Filter worker [" + Thread.CurrentThread.ManagedThreadId + "] for line " +
                           startLine);

            // Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering
            FilterParams threadFilterParams = filterParams.CreateCopy2();

            LogExpert.LogWindow.ColumnizerCallback threadColumnizerCallback = this.callback.createCopy();

            Filter filter = new Filter(threadColumnizerCallback);

            lock (this.filterWorkerList)
            {
                this.filterWorkerList.Add(filter);
            }
            if (this.shouldStop)
            {
                return(filter);
            }
            int realCount = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback);

            Logger.logInfo("Filter worker [" + Thread.CurrentThread.ManagedThreadId + "] for line " + startLine +
                           " has completed.");
            lock (this.filterReadyList)
            {
                this.filterReadyList.Add(filter);
            }
            return(filter);
        }
Ejemplo n.º 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;
              }
            }
          }
        }
      }
    }
Ejemplo n.º 3
0
		private Filter DoWork(FilterParams filterParams, int startLine, int maxCount, ProgressCallback progressCallback)
		{
			Logger.logInfo(string.Format("Started Filter worker [{0}] for line {1}", Thread.CurrentThread.ManagedThreadId, startLine));
			
			// Give every thread own copies of ColumnizerCallback and FilterParams, because the state of the objects changes while filtering
			FilterParams threadFilterParams = filterParams.CreateCopy2();
			LogExpert.ColumnizerCallback threadColumnizerCallback = _callback.createCopy();
			
			Filter filter = new Filter(threadColumnizerCallback);
			lock (_filterWorkerList)
			{
				_filterWorkerList.Add(filter);
			}
			if (_shouldStop)
			{
				return filter;
			}
			int realCount = filter.DoFilter(threadFilterParams, startLine, maxCount, progressCallback);
			Logger.logInfo(string.Format("Filter worker [{0}] for line {1} has completed.", Thread.CurrentThread.ManagedThreadId, startLine));
			lock (_filterReadyList)
			{
				_filterReadyList.Add(filter);
			}
			return filter;
		}
Ejemplo n.º 4
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;
                            }
                        }
                    }
                }
            }
        }