admin管理员组

文章数量:1392050

In my WPF program, the exception to "Cannot re-enter the text formatting processor lasting paragraph formatting optimization." started to pop up at random, I couldn't find a single question about it or its solution, literally. Only Chat GPT answered me that it occurs when attempting to change text in text fields by asynchronous methods. In StackTrace I can't find exactly where the error occurred, it just doesn't refer to any of the methods in my program, the error occurs at random times, happens several times in a row, or may not occur at all, so I can't even track it manually.

Based on (possibly correct?) chat gpt answers I probably should have removed all async methods from the program, but the problem is that no async method exactly interacts with the supposed text field and I have no idea what to do with it.

Did anyone but me ever face this and decide in any way?

And the stacktrace if of course it matters

   at MS.Internal.TextFormatting.TextFormatterImp.AcquireContext(Object owner, IntPtr ploc)
   at MS.Internal.TextFormatting.TextMetrics.FullTextLine.FormatLine(FullTextState fullText, Int32 cpFirst, Int32 lineLength, Int32 formatWidth, Int32 finiteFormatWidth, Int32 paragraphWidth, LineFlags lineFlags, FormattedTextSymbols collapsingSymbol)
   at MS.Internal.TextFormatting.TextMetrics.FullTextLine..ctor(FormatSettings settings, Int32 cpFirst, Int32 lineLength, Int32 paragraphWidth, LineFlags lineFlags)
   at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
   at MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
   at MS.Internal.PtsHost.Line.Format(FormattingContext ctx, Int32 dcp, Int32 width, Int32 trackWidth, TextParagraphProperties lineProps, TextLineBreak textLineBreak)
   at MS.Internal.PtsHost.TextParagraph.FormatLineCore(Line line, IntPtr pbrLineIn, FormattingContext ctx, Int32 dcp, Int32 width, Int32 trackWidth, Boolean firstLine, Int32 dcpLine)
   at MS.Internal.PtsHost.TextParaClient.InputHitTestSimpleLines(FSPOINT pt, FSTEXTDETAILSFULL& textDetails)
   at MS.Internal.PtsHost.TextParaClient.InputHitTest(FSPOINT pt)
   at MS.Internal.PtsHost.PtsHelper.InputHitTestParaList(PtsContext ptsContext, FSPOINT pt, FSRECT& rcTrack, FSPARADESCRIPTION[] arrayParaDesc)
   at MS.Internal.PtsHost.ContainerParaClient.InputHitTest(FSPOINT pt)
   at MS.Internal.PtsHost.PtsHelper.InputHitTestParaList(PtsContext ptsContext, FSPOINT pt, FSRECT& rcTrack, FSPARADESCRIPTION[] arrayParaDesc)
   at MS.Internal.PtsHost.PtsHelper.InputHitTestTrack(PtsContext ptsContext, FSPOINT pt, FSTRACKDESCRIPTION& trackDesc)
   at MS.Internal.PtsHost.PtsPage.InputHitTestPage(FSPOINT pt)
   at MS.Internal.PtsHost.PtsPage.InputHitTest(Point p)
   at MS.Internal.PtsHost.FlowDocumentPage.InputHitTestCore(Point point)
   at MS.Internal.PtsHost.FlowDocumentPage.System.Windows.IContentHost.InputHitTest(Point point)
   at MS.Internal.PtsHost.PageVisual.System.Windows.IContentHost.InputHitTest(Point point)
   at System.Windows.UIElement.InputHitTest(Point pt, IInputElement& enabledHit, IInputElement& rawHit, HitTestResult& rawHitResult)
   at System.Windows.UIElement.InputHitTest(Point point)
   at System.Windows.Shell.WindowChromeWorker._HandleNCHitTest(WM uMsg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Shell.WindowChromeWorker._WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)```

本文标签: