Click here to Skip to main content
15,886,763 members
Home / Discussions / C#
   

C#

 
AnswerRe: Dobble Buffering Pin
Eddy Vluggen10-Apr-16 10:10
professionalEddy Vluggen10-Apr-16 10:10 
QuestionData Entry application using strongly typed dataset Pin
Rajesh Thampi9-Apr-16 18:09
Rajesh Thampi9-Apr-16 18:09 
AnswerRe: Data Entry application using strongly typed dataset Pin
Eddy Vluggen10-Apr-16 10:17
professionalEddy Vluggen10-Apr-16 10:17 
QuestionCalls a method c# Pin
Bougarra8-Apr-16 1:18
Bougarra8-Apr-16 1:18 
AnswerRe: Calls a method c# Pin
OriginalGriff8-Apr-16 1:30
mveOriginalGriff8-Apr-16 1:30 
AnswerRe: Calls a method c# Pin
Richard MacCutchan8-Apr-16 2:49
mveRichard MacCutchan8-Apr-16 2:49 
AnswerRe: Calls a method c# Pin
Rahul Hanumant Chavan8-Apr-16 21:31
professionalRahul Hanumant Chavan8-Apr-16 21:31 
QuestionSpeed up code Pin
GrooverFromHolland8-Apr-16 0:37
GrooverFromHolland8-Apr-16 0:37 
Hi all,

I know that I write crappy code, but the code snippet below takes 16 seconds on my machine in debug and that is unacceptable.

Please help me to speed it up.
C#
string valueString = string.Empty;
          //List<byte> AtronBytes First 39 bytes = header
          int length = AtronBytes.Count - 39;
          for (int i = 0; i < length; i += 8) // length = 1176
          {
              int colNum;
              if (i == 0) colNum = 1;
              else colNum = i / 8 + 1;
              string column = machineDataColumnNames[colNum];
              //tempAtronBytes = copy of AtronBytes
              byte[] valueByte = tempAtronBytes.GetRange(0, 8).ToArray();
              // last byte of valueByte = checksum
              byte chkVal = Extentions.CalculateOpdrChecksum(tempAtronBytes.GetRange(0, 7).ToArray()); // 1ms
              if (chkVal == tempAtronBytes[7])// checksum test
              {
                  valueString = Encoding.ASCII.GetString(
                                tempAtronBytes.GetRange(0, 7).ToArray()).Trim();
                  // Remove value bytes and checksum:
                  tempAtronBytes.RemoveRange(0, 8);

                  SqlCeExtentions.ZakdataDatabase_Update(column, valueString, opdrString); // 87ms
                  // add to stringBuilder:
                  logAppend(column.PadRight(30), valueString);
                  //Show in richTextbox
                  if (colNum > 146)
                  {
                      logResult();
                  }
              }
              else
              {
                  MessageBox.Show("Checksum error");
                  return;
              }
          }


Thanks,
Groover
0200 A9 23
0202 8D 01 80
0205 00

AnswerRe: Speed up code Pin
OriginalGriff8-Apr-16 1:12
mveOriginalGriff8-Apr-16 1:12 
AnswerRe: Speed up code PinPopular
Sascha Lefèvre8-Apr-16 1:20
professionalSascha Lefèvre8-Apr-16 1:20 
GeneralRe: Speed up code Pin
OriginalGriff8-Apr-16 1:34
mveOriginalGriff8-Apr-16 1:34 
GeneralRe: Speed up code Pin
GrooverFromHolland8-Apr-16 1:52
GrooverFromHolland8-Apr-16 1:52 
GeneralRe: Speed up code Pin
Sascha Lefèvre8-Apr-16 2:41
professionalSascha Lefèvre8-Apr-16 2:41 
GeneralRe: Speed up code Pin
Eddy Vluggen8-Apr-16 2:54
professionalEddy Vluggen8-Apr-16 2:54 
AnswerRe: Speed up code Pin
Gerry Schmitz8-Apr-16 7:24
mveGerry Schmitz8-Apr-16 7:24 
GeneralRe: Speed up code Pin
GrooverFromHolland18-Apr-16 23:59
GrooverFromHolland18-Apr-16 23:59 
GeneralRe: Speed up code Pin
Gerry Schmitz19-Apr-16 4:58
mveGerry Schmitz19-Apr-16 4:58 
AnswerRe: Speed up code Pin
Patrice T9-Apr-16 0:01
mvePatrice T9-Apr-16 0:01 
GeneralRe: Speed up code Pin
GrooverFromHolland9-Apr-16 1:56
GrooverFromHolland9-Apr-16 1:56 
GeneralRe: Speed up code Pin
Patrice T9-Apr-16 5:09
mvePatrice T9-Apr-16 5:09 
Question.NET Remoting connection timing out after many invocations Pin
RichardGrimmer7-Apr-16 20:30
RichardGrimmer7-Apr-16 20:30 
AnswerRe: .NET Remoting connection timing out after many invocations Pin
Richard Andrew x648-Apr-16 3:42
professionalRichard Andrew x648-Apr-16 3:42 
AnswerRe: .NET Remoting connection timing out after many invocations Pin
Dikshitar V.9-Apr-16 10:23
Dikshitar V.9-Apr-16 10:23 
QuestionLocal Service to monitor a folder on desktop Pin
Blubbo7-Apr-16 9:40
Blubbo7-Apr-16 9:40 
AnswerRe: Local Service to monitor a folder on desktop Pin
Richard Deeming7-Apr-16 10:25
mveRichard Deeming7-Apr-16 10:25 

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.