I'm currently using a TimeControl Sub that is run on the GUI thread (.i.e. this Sub is called from a Menu.Click routine)
Using it that way the simulation works and is displayed by the GUI.Code:Public Sub TimeControl Static LastSimTime As Integer = Enviroment.TickCount Dim ActualTime As Integer Try ActualTime = Enviroment.TickCount If LastSimTime + StepIntervall >= ActualTime Then Simulation 'This Sub that starts all the BackGroundWorkers(BGW) that do the calculation of movements LastSimTime = ActualTime End If If StartStop = True Then ExecuteAfterPause(StepIntervall, New MethodInvoker( Adressof TimeControl) ' This Sub calls itself as long as StartStop is True End If Catch ex As Exeption '..... End Try End Sub
However sole GUI actions (like measurment of distance) migth delay the TimeControl. For that reason I would like to use another BGW.
In the Menu.Click this BGW is just started as "BGW.RunWorkerAsync()" and the TimeControl Sub is called in the BGW_DoWork Sub.
Using it that way the GUI is only updated when moving the mouse. I even tried to put "MainForm.BGW.ReportProgress(1)" in the TimeControl and
(with BGW.WorkerReportsProgress = True)Code:Private Sub BGW_ProgressChanged.... Me.Update End Sub
with no change.
In my understanding the .ProgressChanged is handeld on the GUI threat, therefore I did expect the Me.Update the show the actual data as does the movement of the mouse.
Where am I wrong????




Reply With Quote