多线程 - 将点添加到 VB 中的系列
Multithreading - Add point to series in VB
美好的一天
一张图表添加了一组 3 个系列,形式为:
(chrtReadTimePlot is private)
chrtRealTimePlot.Series.Add(SerRT_B_Voltage)
chrtRealTimePlot.Series.Add(SerRT_Charge_Current)
chrtRealTimePlot.Series.Add(SerRT_P_Voltage)
每个系列都有其 get set
方法
问题:每个系列都有基于Threading.Timer.Tick():
添加的数据点
SerRT_B_Voltage.Points.AddXY(MPPTdata(x1,y1)
SerRT_Charge_Current.Points.AddXY(x2,y2)
SerRT_P_Voltage.Points.AddXY(MPPTdata(x3,y)
向其中一个系列添加一个点时,出现跨线程错误。
错误:
An unhandled exception of type 'System.InvalidOperationException'
occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control
'chrtRealTimePlot' accessed from a thread other than the thread it was
created on.
我不知道在这种情况下如何使用调用
任何 thoughts/suggestions 都会有很大的帮助!
无法评论,因为我没有足够的评分...
您必须使用委托才能从另一个线程安全地更新 GUI。读这个:http://tech.xster.net/tips/invoke-ui-changes-across-threads-on-vb-net/
当我遇到同样的问题时,这篇文章对我很有帮助。
美好的一天
一张图表添加了一组 3 个系列,形式为:
(chrtReadTimePlot is private)
chrtRealTimePlot.Series.Add(SerRT_B_Voltage)
chrtRealTimePlot.Series.Add(SerRT_Charge_Current)
chrtRealTimePlot.Series.Add(SerRT_P_Voltage)
每个系列都有其 get set
方法
问题:每个系列都有基于Threading.Timer.Tick():
添加的数据点SerRT_B_Voltage.Points.AddXY(MPPTdata(x1,y1)
SerRT_Charge_Current.Points.AddXY(x2,y2)
SerRT_P_Voltage.Points.AddXY(MPPTdata(x3,y)
向其中一个系列添加一个点时,出现跨线程错误。
错误:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Cross-thread operation not valid: Control 'chrtRealTimePlot' accessed from a thread other than the thread it was created on.
我不知道在这种情况下如何使用调用
任何 thoughts/suggestions 都会有很大的帮助!
无法评论,因为我没有足够的评分...
您必须使用委托才能从另一个线程安全地更新 GUI。读这个:http://tech.xster.net/tips/invoke-ui-changes-across-threads-on-vb-net/
当我遇到同样的问题时,这篇文章对我很有帮助。