RichEditBox performance is slow when loading large text files

Abhishek 21 Reputation points
2020-06-15T05:09:14.89+00:00

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?

Universal Windows Platform (UWP)
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Matt Lacey 786 Reputation points Microsoft MVP
    2020-06-15T11:32:25.1+00:00

    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.

    No comments

  2. 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 a List<String>, and then only a part is loaded at a time.

    Thanks.

    No comments