Posted 8 September 2017, 5:29 am EST
For certain reason, if you have a chart, and you try to load data to a sheetview a second time. It would be very slow.
Here are the steps to reproduce the problem:
1. Download the zip file
2. Compile it
3. there are 2 combo box, select the one at the top, change the index to 0. Note that it takes only a short time for the graph to come up
4. Now change the index to 1, it now takes a loong time for the graph to come up.
5. If you profile it, you will find that this method is the bottleneck:
private double[,] LoadData(int index)
{
var doubMatrix = new double[6000, 2];
for (int i = 0; i < doubMatrix.GetLength(0); i++)
{
for (int j = 0; j < doubMatrix.GetLength(1); j++)
{
if (j == 0)
{
doubMatrix[i, j] = i;
}
else
{
doubMatrix[i, j] = 2*(doubMatrix[i, 0]+index);
}
}
}
return doubMatrix;
}