private void RefreshBasicList() { #pragma warning disable VSTHRD001 // Avoid legacy thread switching APIs Dispatcher.InvokeAsync(() => { Vm.RefreshBasicList(); _lastModel = Vm.List; }); #pragma warning restore VSTHRD001 // Avoid legacy thread switching APIs }
/// <summary> /// Refresh the view periodically /// </summary> private void OnRenderFrameCompleted(object sender, RenderFrameEventArgs e) { if (Vm.ScreenRefreshCount % 100 == 0) { #pragma warning disable VSTHRD001 // Avoid legacy thread switching APIs Dispatcher.Invoke(() => { var newModel = Vm.CreateBasicListViewModel(); newModel.DecodeBasicProgram(); if (!BasicListViewModel.Compare(_lastModel, newModel)) { Vm.RefreshBasicList(); _lastModel = newModel; } }); #pragma warning restore VSTHRD001 // Avoid legacy thread switching APIs } }
/// <summary> /// Compares this view model with another /// </summary> /// <param name="other">Other view model</param> /// <returns>True, if the two view models are equal; otherwise, false</returns> public static bool Compare(BasicListViewModel thisModel, BasicListViewModel other) { if (other == null) { return(false); } if (other.ProgramLines.Count != thisModel.ProgramLines.Count) { return(false); } for (var i = 0; i < thisModel.ProgramLines.Count; i++) { var otherItem = other.ProgramLines[i]; var thisItem = thisModel.ProgramLines[i]; if (otherItem.LineNo != thisItem.LineNo || otherItem.Length != thisItem.Length || otherItem.Text != thisItem.Text) { return(false); } } return(true); }