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

C#

 
Question(wpf) Panning & zooming Pin
Frostsnow24-Apr-07 2:11
Frostsnow24-Apr-07 2:11 
Questionhow to create an array right, if you don't know its length in advance Pin
greenpci24-Apr-07 1:49
greenpci24-Apr-07 1:49 
AnswerRe: how to create an array right, if you don't know its length in advance Pin
Christian Graus24-Apr-07 1:55
protectorChristian Graus24-Apr-07 1:55 
Generalspeed boost Pin
V.24-Apr-07 1:31
professionalV.24-Apr-07 1:31 
GeneralRe: speed boost Pin
althamda24-Apr-07 1:54
althamda24-Apr-07 1:54 
GeneralRe: speed boost Pin
Christian Graus24-Apr-07 1:59
protectorChristian Graus24-Apr-07 1:59 
GeneralRe: speed boost Pin
V.24-Apr-07 2:18
professionalV.24-Apr-07 2:18 
GeneralRe: speed boost Pin
Pete O'Hanlon24-Apr-07 4:04
mvePete O'Hanlon24-Apr-07 4:04 
I had a play round with this, and got a 21 MB file to process in about 10 seconds. This code isn't perfect, but it is a decent basis to carry on with:
public void ReadFile()
{
  if (openfiledialog.ShowDialog() == DialogResult.OK)
  {
    System.IO.StreamReader reader = new System.IO.StreamReader(openfiledialog.FileName); 
    StringBuilder text1 = new StringBuilder(reader.ReadToEnd()); 
    reader.Close(); 
    pb_conversion.Maximum = text1.Length; 
    DateTime starttime = DateTime.Now; 
    //Starting from 1 will gain me 1 character less to analyze. 
    int innercount = 0;
    for(int i = 1; i < text1.Length; i+=2)
    { 
      text1[i] = text1[i].ToString().ToUpper()[0];
      if (++innercount == 1000)
      {
        innercount = 0;
        pb_conversion.Value = i; 
      }
    }
    txtbox_result.Text = text1.ToString();
    TimeSpan difference = DateTime.Now - starttime;
    MessageBox.Show(difference.ToString());
  }
}
One of the key areas is that you no longer attempt to update the progress bar every iteration. This is just wasteful and should be avoided - which is why I update every 1000 iterations.

Deja View - the feeling that you've seen this post before.

GeneralRe: speed boost Pin
V.24-Apr-07 4:14
professionalV.24-Apr-07 4:14 
GeneralRe: speed boost Pin
Pete O'Hanlon24-Apr-07 4:22
mvePete O'Hanlon24-Apr-07 4:22 
GeneralRe: speed boost Pin
althamda24-Apr-07 4:41
althamda24-Apr-07 4:41 
GeneralRe: speed boost Pin
Pete O'Hanlon24-Apr-07 5:17
mvePete O'Hanlon24-Apr-07 5:17 
QuestionHow to copy a string into a byte[] Pin
GDavy24-Apr-07 1:16
GDavy24-Apr-07 1:16 
AnswerRe: How to copy a string into a byte[] Pin
stancrm24-Apr-07 1:18
stancrm24-Apr-07 1:18 
AnswerRe: How to copy a string into a byte[] Pin
szukuro24-Apr-07 1:23
szukuro24-Apr-07 1:23 
AnswerRe: How to copy a string into a byte[] Pin
lmoelleb24-Apr-07 1:24
lmoelleb24-Apr-07 1:24 
GeneralRe: How to copy a string into a byte[] Pin
GDavy24-Apr-07 1:26
GDavy24-Apr-07 1:26 
QuestionProblem in trying to hide MenuStipItems from a static function Pin
Rocky#24-Apr-07 1:11
Rocky#24-Apr-07 1:11 
AnswerRe: Problem in trying to hide MenuStipItems from a static function Pin
kubben24-Apr-07 2:02
kubben24-Apr-07 2:02 
QuestionHow can I scroll to the beginning of a treeView? Pin
AngryC24-Apr-07 1:09
AngryC24-Apr-07 1:09 
QuestionDynamic Creation of field objects/section in Crystal report Pin
renjithgk24-Apr-07 0:42
renjithgk24-Apr-07 0:42 
AnswerRe: Dynamic Creation of field objects/section in Crystal report Pin
Rocky#24-Apr-07 1:14
Rocky#24-Apr-07 1:14 
Questioncan we get the ID's of the corresponding checkbox when the checkbox is checked? [modified] Pin
tirumal123124-Apr-07 0:28
tirumal123124-Apr-07 0:28 
Questionurgent Pin
ram.rnkvs24-Apr-07 0:25
ram.rnkvs24-Apr-07 0:25 
AnswerRe: urgent Pin
Keshav V. Kamat24-Apr-07 0:27
Keshav V. Kamat24-Apr-07 0:27 

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.