Re: Read text file to Temp file and apply formating and color chan



Brian Cook wrote:
It takes 3Min30Sec for a 7MB file.

I am runing a P4 3.4Mhz PC with 2GB of RAM.

I assume that's "3.4Ghz", you mean. :)

Maybe you could post a concise-but-complete example of code that reliably demonstrates your scenario. I am not seeing nearly so awful a performance result.

I created a short application that simply puts 7MB worth of dummy text into a RichTextBox. Actually, it's technically 14MB...I took the conservative view that your "7MB file" is regular ASCII, and so I actually generate 7 * 1024 * 1024 characters. Since .NET uses Unicode, this is actually 14MB, not 7MB.

I generate the dummy text randomly one character at a time, one fake sentence at a time, appending each new sentence to a StringBuilder that has been preinitialized to the 7 million (or so :) ) characters. Then I use the ToString() method and assign the result to the Text property of the RichTextBox.

I ran this on my Core 2 Duo 2.33Ghz computer with 2GB of RAM.

The initialization of the data takes roughly 1 second, and roughly another 3 seconds to copy it all to the RichTextBox.

So yes, there's a fair amount of overhead in the control, relatively speaking (copying the text takes three times as long as generating it in the first place). But three and a half minutes is WAY too slow. I don't know what you're code is doing, but it seems likely to me that you have some basic algorithmic issues going on, and your problem will be better solved addressing those rather than looking for ways to make the control itself faster. My experiment suggests that the control itself has acceptable performance, when used efficiently.

IMHO, the best sample code would include something that autogenerates the data equivalent to your 7MB file, and which also includes whatever initialization code you are using, along with a RichTextBox contained by the form for the program. In other words, the program itself should be as small as possible (no downloading 7MB files :) ), but should still reproduce the same performance results you're seeing, by doing the exact same initialization you're doing.

Pete
.



Relevant Pages

  • Re: RichTextBox text on MDI Parent form Undo Redo etc
    ... the richtextbox, will try the undo method from the child form. ... controls on the form, the child form contains the tab control and this ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: using EM_GETRECT vs. using EM_GETLINECOUNT with a RichTextBox
    ... RichTextBox with both BorderStyle and Scrollbars set to none. ... public struct REQRESIZE ... public const int WM_NOTIFY = 0x4E; ... Control tb = Control.FromHandle; ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Result of RichTextBox.AppendText of too many characters?
    ... Do the oldest characters it contains start ... Neither TextBox nor RichTextBox have any sort of automatic discarding of data. ... You can probably squeeze a little more capacity out of the control by using TextBox instead. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: AutoSizing a RichTextBox Control
    ... calculate the size of an RTF control would be wonderful! ... For a RichTextBox control, the RichTextBox.Multiline property affects ... RichTextBox will not automatically resize. ... How do I handle resizing the richtextbox height when I want it to display? ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Rich text controls in Access 2003
    ... Newsgroup: microsoft.public.fr.access ... RichTextBox of my base of donn E programm E under access 2002 are not ... For this Microsoft reason prevents its execution in Internet To ... You could then use, for example, control ActiveX ...
    (microsoft.public.access.forms)

Loading