我正在使用 MSChart 实时绘制应用程序...我需要设置一些 y 值,NaN
但我遇到了溢出异常。这是发生它的代码部分:
if (j_ecg < 2569)
{
for (int i = 0; i < 32; i++)
{
this.Invoke((MethodInvoker)delegate
{
ECG.Points.AddXY(puntos_ecg[j_ecg].X,puntos_ecg[j_ecg].Y);
});
j_ecg++;
}
}
else
{
for (int i = 0; i < 32; i++)
{
this.Invoke((MethodInvoker)delegate
{
ECG.Points[ecg_s].SetValueY(puntos_ecg[j_ecg].Y);
for (int j = 1; j < 10; j++){ ECG.Points[ecg_s + j].SetValueY(double.NaN); }
});
j_ecg++;
ecg_s++;
if (ecg_s == 2560) { ecg_s = 0; }
}
}
调用是为了避免跨线程问题。
知道如何才能避免异常吗?我尝试在SetValueY
通话之前使用 unchecked 关键字,但没有任何变化。