at first when i started the thread which calls the following function DrawDTSRanksChart() it gave me an error "The calling thread must be STA, because many UI components require this"
after adding the follwing line to the thread call
UpdateThread.SetApartmentState(ApartmentState.STA)
"The calling thread cannot access this object because a different thread owns it"
the commented line throws both exception
Public Update Thread As System.Threading.Thread
Private Sub DrawDTSRanksChart()
Dim DTSRankingDiagram As New XYDiagram2D
Dim series1 As New AreaFullStackedSeries2D
ChartControl1.Diagram = DTSRankingDiagram 'this line throws the exption
DTSRankingDiagram.Series.Add(series1)
series1.Points.Add(New SeriesPoint("Ranked 1.", DTSr1counter))
series1.Points.Add(New SeriesPoint("Ranked 2.", DTSr2counter))
series1.Points.Add(New SeriesPoint("Ranked 3.", DTSr3counter))
series1.Points.Add(New SeriesPoint("Ranked >3.", DTSrm3counter))
End Sub
Private Sub save_Clicked(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles NormalUpdate.ItemClick
UpdateThread = New System.Threading.Thread(AddressOf update)
UpdateThread.SetApartmentState(ApartmentState.STA)
UpdateThread.Start()
End Sub
i just need a background worker so my UI doesnt hang