小白请教大内高手如何将线程里的数组显示在控件上。代码贴上
private void backgroundWorker1_DoWork_1(object sender, DoWorkEventArgs e) {
UInt16[] RegisterValue1 = new UInt16[0];
UInt16[] RegisterValue2 = new UInt16[0];
int[] name = new int[2];
BackgroundWorker worker = sender as BackgroundWorker;
while (worker.CancellationPending == false)
{
RegisterValue1 = Master.ReadHoldingRegisters(1, 4096, 1);
RegisterValue2 = Master.ReadHoldingRegisters(1, 4102, 1);
n = Convert.ToInt16(RegisterValue1[0]);
nn = Convert.ToInt16(RegisterValue2[0]);
name[1] = (ushort)n;
name[2] = (ushort)nn;
// worker.ReportProgress(0, n);
Thread.Sleep(1);
}
}