UWP-InkCanvas上InkToolbar上的自定义撤消和重做-未处理System.ExecutionEngineeException

UWP-InkCanvas上InkToolbar上的自定义撤消和重做-未处理System.ExecutionEngineeException,uwp,windows-10-universal,inkcanvas,Uwp,Windows 10 Universal,Inkcanvas,正在尝试在InkCanvas上创建自定义撤消和重做。然而,经过一些压力测试(添加大量笔划、多次撤消和重做),应用程序崩溃: System.ExecutionEngineeException未处理。HResult=-2146233082 在我的addToRedList方法的foreach循环上。有人知道如何捕获和修复异常吗 private void AddToRedoList(InkStroke addStroke) { var addInkPoint = addStroke.GetInkPo

正在尝试在
InkCanvas
上创建自定义撤消和重做。然而,经过一些压力测试(添加大量笔划、多次撤消和重做),应用程序崩溃:

System.ExecutionEngineeException未处理。HResult=-2146233082

在我的
addToRedList
方法的foreach循环上。有人知道如何捕获和修复异常吗

private void AddToRedoList(InkStroke addStroke) {
  var addInkPoint = addStroke.GetInkPoints();
  var addInkPointList = new List<InkPoint>();
  foreach (var point in addInkPoint) {
    addInkPointList.Add(new InkPoint(point.Position, point.Pressure));
  }

  redoCustomStrokeList.Add(new CustomStroke() {
    InkPoints = addInkPointList,
    DrawingAttributes = addStroke.DrawingAttributes
  });
}

private void UndoOnClick(object sender, RoutedEventArgs e) {
  var allStrokes = InkImage.InkPresenter.StrokeContainer.GetStrokes();
  var undoStroke = allStrokes[allStrokes.Count - 1];
  AddToRedoList(undoStroke);

  allStrokes[allStrokes.Count - 1].Selected = true;
  InkImage.InkPresenter.StrokeContainer.DeleteSelected();
}

private void RedoOnClick(object sender, RoutedEventArgs e) {
  var lastRedoInkPoints = redoCustomStrokeList[redoCustomStrokeList.Count-1];
  InkImage.InkPresenter.StrokeContainer.AddStroke(CreateStroke(lastRedoInkPoints));
    redoCustomStrokeList.Remove(lastRedoInkPoints);
  }
}
private void AddToRedoList(InkStroke addStroke){
var addInkPoint=addStroke.GetInkPoints();
var addInkPointList=新列表();
foreach(附加点中的变量点){
addInkPointList.Add(新的着墨点(point.Position,point.Pressure));
}
redoCustomStrokeList.Add(新建CustomStroke()){
InkPoints=addInkPointList,
DrawingAttributes=addStroke.DrawingAttributes
});
}
私有void undonclick(对象发送方,RoutedEventArgs e){
var allStrokes=InkImage.InkPresenter.StrokeContainer.GetStrokes();
var undostrope=allStrokes[allStrokes.Count-1];
AddToRedoList(取消行程);
allStrokes[allStrokes.Count-1]。Selected=true;
InkImage.InkPresenter.StrokeContainer.DeleteSelected();
}
私有void RedoOnClick(对象发送方,RoutedEventArgs e){
var lastRedoInkPoints=redoCustomStrokeList[redoCustomStrokeList.Count-1];
InkImage.InkPresenter.StrokeContainer.AddStroke(CreateStroke(lastRedoInkPoints));
redoCustomStrokeList.Remove(lastRedoInkPoints);
}
}

您能提供整个项目吗?上面的代码是缺乏的,可能无法复制你的问题在我这边。你能提供整个复制项目吗?上面的代码是缺乏的,可能无法复制您的问题在我这边。