Click here to Skip to main content
16,016,570 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Application communicates with several instruments to perform read and write operation.Main objective of application is execution of testcases.

We are need of execute the 12321 testcases, but after the completion of 1332 testcases the app gets slower execution.

created the single thread for executing all testcases, to perform UI update given below code
C#
RichTextBoxControl.Dispatcher.Invoke(
    new Common.DisplayActualResult(uiDisplay.Display), 
    new object[] 
    { 
        analyzerDisplay 
    }
);


suggest the comments to improve the performance.
Posted

We can't, not from that - and without your actual hardware setup, we can't duplicate your problem either.

We have absolutely no idea how your system works, much less how it fails when it slows down.
Start by getting yourself some numbers on what is slowing down: use the StopWatch class to start logging information about how long various operations are taking, and look at the results to try and see what parts of your code are actually taking longer. You can then refine your measurements to focus on how the "slowing code" is built up, and find what parts of that are slowing down. And so forth.

But there is no "miracle cure", nothing that works for everybody - you need to work out what is getting slower, because until then nobody can even begin to suggest cures.

Sorry it's general - but there is nothing we can do from here.
 
Share this answer
 
I'll make a guess as I see that you may be using that RichTextBox (RTB) as a log.

Updating via the Text property gets slower as the existing RTB data length increases and the AppendText method is much better.

However the AppendText method also suffers from a similar slow down and it is best to create a group of text within a StringBuilder and then make one call to AppendText.

C#
private void UpdateMethods() {
  String OneLineOfData = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + Environment.NewLine;
  const Int32 LinesToAdd = 10000;
  // Bad
  for (Int32 i = 0; i < LinesToAdd; i++) {
    rtb.Text += OneLineOfData;
  }

  // Better
  for (Int32 i = 0; i < LinesToAdd; i++) {
    rtb.AppendText(OneLineOfData);
  }

  // Best by far - one call of AppendText
  StringBuilder sb = new StringBuilder(OneLineOfData.Length * LinesToAdd);
  for (Int32 i = 0; i < LinesToAdd; i++) {
    sb.Append(OneLineOfData);
  }
  rtb.AppendText(sb.ToString());
}

Alan.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900