c# - Application unresponsive when highlighting matched string in richTextBox1; input large .txt file -


I am creating a simple log parsing / reading application that aims to highlight a matching string (user-defined input) When trying, it becomes unresponsive and the log file line string for the large file file (1.5 MB or greater) was found within richTextBox1 small text files work fine matching lines look ok Match string There exists a problem while trying to light (when matching string is found more and more).

  // Select the user in the app * .txt file and process the content for the string [], not the file streaming. // The list of matching strings is created // Matched strings are displayed in RichTextBox1 stringbilder RTBtext = new stringbilders (rich textbox 1. text); If (displayMatched! = Null & amp; DisplayMetched.Length & gt; 0) {// shows the row of the log file which entered for (int s = 0; s & lt; displayMatched.Length; s ++) String corresponds to {RTBtext.Append (Displaced [S] + Environment. NewLine); }} RichTextBox1.Text = RTBtext.ToString (); / / // New line \ n Added / display debugging between matching line to increase readability shows "hot line" with large CPU usage, starts here: While (index  

A similar style loop is executed in any other part of the program without any problems. Do I have problems with indexing? Is the CPU working so hard? Display debugging state System.Windows.Forms.RichTextBox.get_Text (); is the biggest obstacle.

I have tried richTextBox1.SuspendLayout and with any luck (also RTB1.SuspendPainting / ResumePainting ) With ResumeLayout .

Is it possible to highlight only, say, 200 lines of matching strings at about one time, then continue with richTextBox1.VScrollBar ? If so, what is the best way to accomplish this?

In my experience, rich textbox does not play well in large quantities (megabyte +) text Has been loaded at a time.

My recommendation will directly process the text file upon applying the search file, and store all the match byte offsets and length in a different hashet / dictionary.

Once you have a collection of line numbers and byte offsets, you can dynamically write text in RichTextBox on the scroll position (aka infinite scroll). Every time you add a new text to the RTB, you check the byte status in the hashets done in the previous step. If you find a match byte offset, then you can go ahead and mark-up your text at this time. Do not forget to remove the text from the beginning of the RTB, as if you are adding it.

The way in which I personally handle this application, in addition to the above, there is a separate abstract view that matches the line numbers and their content. In this way, I can have a grep-like view of the document for all the matches, when clicking on the summary view match item, it will scroll the main view of the RTB at that point in the document so that I can register entries around one of the concerns Can check.

Before using these techniques, handle handling gigabyte size logs.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -