Click here to Skip to main content
15,888,232 members
Home / Discussions / C#
   

C#

 
GeneralRe: How Inherits...Implements...in C# Pin
Scott Dorman26-Apr-07 5:32
professionalScott Dorman26-Apr-07 5:32 
GeneralRe: How Inherits...Implements...in C# Pin
Colin Angus Mackay26-Apr-07 5:44
Colin Angus Mackay26-Apr-07 5:44 
GeneralRe: How Inherits...Implements...in C# Pin
ASysSolvers26-Apr-07 5:50
ASysSolvers26-Apr-07 5:50 
AnswerRe: How Inherits...Implements...in C# Pin
Scott Dorman26-Apr-07 5:31
professionalScott Dorman26-Apr-07 5:31 
GeneralRe: How Inherits...Implements...in C# Pin
ASysSolvers26-Apr-07 5:53
ASysSolvers26-Apr-07 5:53 
AnswerRe: How Inherits...Implements...in C# Pin
ASysSolvers27-Apr-07 5:33
ASysSolvers27-Apr-07 5:33 
QuestionMove scrollable pane from function Pin
Stumproot26-Apr-07 3:42
Stumproot26-Apr-07 3:42 
Generalsetting large amount of text in textbox Pin
V.26-Apr-07 2:56
professionalV.26-Apr-07 2:56 
Guys,

A few days ago I asked about an assignment we had to do here at work. convert "aabb" to "aAbB" and set it to the textbox as quickly as possible. I think the conversion itself is very quick, reading in and converting in 1 or 2 seconds, but setting the entire thing in the texbox takes me another 10 seconds! (20 MB file)

I've read about the AppendText property and tried to set my characterarray to the box inside my loop, but so far the fastest results I got where form txtbox_result.Text = new string(text); where text = char [].

Any ideas on how to speed this up? (Suspend/resumelayout don't help either)

thanks !


PS: here's tho code I got so far:
starttime = DateTime.Now;
reader = new System.IO.StreamReader(openfiledlg.FileName);
char [] text = reader.ReadToEnd().ToCharArray();
reader.Close();
difference = DateTime.Now - starttime;
lbl_result.Text = "File read: " + difference.TotalMilliseconds + " milliseconds.";
lbl_result.Refresh();
pb_conversion.Maximum = text.Length;
//Starting from 1 will gain me 1 character less to analyze.
//don't update the progress bar every iteration.
int i2 = 0;
for(int i = 1; i < text.Length; i+=2){
    text[i] = char.ToUpper(text[i]);
    if(++i2 == 1000){
        i2 = 0;
        pb_conversion.Value = i;
    }                                           //end if
}                                               //end for
difference = DateTime.Now - starttime;
lbl_result.Text = "conversion: " + difference.TotalMilliseconds + " milliseconds.";
lbl_result.Refresh();
pb_conversion.Value = pb_conversion.Maximum;
txtbox_result.SuspendLayout();
txtbox_result.Text = new string(text);
txtbox_result.ResumeLayout();
difference = DateTime.Now - starttime;
lbl_result.Text = "Done in: " + difference.TotalMilliseconds + " milliseconds.";




V.
I found a living worth working for, but haven't found work worth living for.

GeneralRe: setting large amount of text in textbox Pin
Marek Grzenkowicz26-Apr-07 3:42
Marek Grzenkowicz26-Apr-07 3:42 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:02
professionalV.26-Apr-07 4:02 
GeneralRe: setting large amount of text in textbox Pin
.jpg26-Apr-07 4:09
.jpg26-Apr-07 4:09 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:15
professionalV.26-Apr-07 4:15 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:12
althamda26-Apr-07 4:12 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:21
professionalV.26-Apr-07 4:21 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:25
althamda26-Apr-07 4:25 
GeneralRe: setting large amount of text in textbox Pin
mav.northwind26-Apr-07 9:52
mav.northwind26-Apr-07 9:52 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 22:58
althamda26-Apr-07 22:58 
GeneralRe: setting large amount of text in textbox Pin
mav.northwind27-Apr-07 8:16
mav.northwind27-Apr-07 8:16 
GeneralRe: setting large amount of text in textbox Pin
lmoelleb26-Apr-07 19:50
lmoelleb26-Apr-07 19:50 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:39
althamda26-Apr-07 4:39 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:44
professionalV.26-Apr-07 4:44 
GeneralRe: setting large amount of text in textbox Pin
althamda26-Apr-07 4:46
althamda26-Apr-07 4:46 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 4:51
professionalV.26-Apr-07 4:51 
GeneralRe: setting large amount of text in textbox [modified] Pin
althamda26-Apr-07 4:59
althamda26-Apr-07 4:59 
GeneralRe: setting large amount of text in textbox Pin
V.26-Apr-07 7:37
professionalV.26-Apr-07 7:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.