You could try adding the text a bit at a time (rather than all at once) and releasing the UI thread between each bit you add.
If the file must all be loaded and the contents can't be changed to make loading faster, you'll have to change the way it is loaded to minimize the time the UI is blocked.
RichEditBox performance is slow when loading large text files

RichEditBox hangs UI when loading the larger text files.
File read operation takes 1 ms time but when we are setting data to richeditbox, it will hangs UI (for 2 seconds) and also loader looks likes stuck (unresponsive).
Is there any way of increase the performance of RichEditBox?
2 answers
Sort by: Most helpful
-
Matt Lacey 791 Reputation points MVP
2020-06-15T11:32:25.1+00:00 -
Richard Zhang-MSFT 6,921 Reputation points
2020-06-15T11:52:19.07+00:00 Hello,
Welcome to Microsoft Q&A!
If you load a lot of text at once, the text will be rendered on the UI thread, which means the UI will get stuck.
For text controls such as
RichTextBlock
, the text is usually sliced.For example, the novel can be separated according to chapters, a
String
is processed into aList<String>
, and then only a part is loaded at a time.Thanks.