2016-02-28 29 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如果你想運行的異步/不需要等待操作上的其他線程完成)

相關問題