2016-02-28 103 views
0

我想在某些情况下更新我的图表。我用另一种方法打电话给Plot。我发现this解决方案,但它是为textBox,所以我不能实现它到我的代码。我在互联网上搜索,但我找不到图表的解决方案。跨线程操作无效:从其创建的线程以外的线程访问控制'chart1'

如何解决向图表添加点的问题?

private void Plot() 
    { 
      chart1.Series["test1"].Points.AddXY 
          (plotValues[0,1], plotValues[0,0]); 
      chart1.Series["test1"].Points.AddXY 
          (plotValues[1, 1], plotValues[1, 0]); 

    } 
+0

到底是什么的答案的问题在你的链接? –

回答

0
Dispatcher.Invoke(() => chart1.Series["test1"].Points.AddXY 
         (plotValues[0,1], plotValues[0,0])); 

(或InvokeAsync如果你想运行的异步/不需要等待操作上的其他线程完成)

相关问题