void modelSimEngine_AnimationRunning(int t) { // Update the track bar if (trackBar.InvokeRequired) { UpdateTrackProgress d = new UpdateTrackProgress(modelSimEngine_AnimationRunning); this.Invoke(d, new object[] { t }); } else { // Pay attention to this call which often throw a exception // So I would like to catch the exception try { trackBar.Value = t; GetModelAnimationSimulationEngine().UpdateModelByProgress(t); } catch (Exception ex) { string errMsg = ex.Message + "\n" + ex.StackTrace; vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg); } } }
private void ReplayAnimationEngine_AnimationRunning(int t) { // Notice this maybe a unsafe thread call. if (trackBarAnimation.InvokeRequired) { UpdateTrackProgress d = new UpdateTrackProgress(ReplayAnimationEngine_AnimationRunning); this.Invoke(d, new object[] { t }); } else { if (IApp.theApp.RenderWindow.CheckInRenderStatus() != 0) { return; } // The current observer mode instance must be CReplayMode CReplayMode replayMode = IApp.theApp.ObserverModeManager.ActiveModeInstance as CReplayMode; if (replayMode == null) return; // Update the control value try { trackBarAnimation.Value = t; // Drive model DriveModeByTrackBarValue(replayMode, t); } catch (Exception ex) { string errMsg = ex.Message + "\n" + ex.StackTrace; vtk.vtkOutputWindow.GetInstance().DisplayErrorText(errMsg); } } }