WPF RichTextBox Performance Issues

WPF RTB is terribly slow when working with any realistic amount of text. And by the real amount, I mean what you expect any text editor to be able to process (at least 100 kb) without showing any signs of slowness.

This expected RTB behavior is not for me. In fact, management works pretty much the way it does when text is neatly divided into small words and small paragraphs, and I implement some kind of mechanism that will block my users when they become brave and type something much longer . I have not yet found a way to implement the mentioned mechanism, so instead I have to (or at least try) to solve the problem.

I find it deeply disturbing because it makes no sense to me. If you are a daredevil and accidentally type one long line of characters without a space or a pause, you become a victim of a locked window for several seconds, making a printed reaction to an undesirable test of patience. I want to know why this is so? In particular, why does it slow down more and more, and only when the text is not spaced sequentially? Am I crazy to consider the case that someone using my program will have a broken space and thus be more likely to notice this incredible slowdown? Text selection is also seriously affected in this case with a continuous line.

I am targeting .NET 4.0 using VS 2010 and no events are connected to RTB; for testing purposes, this is an empty window except RTB ( < RichTextBox/">). What can I do to improve its performance? Is it more realistic to just write your own control for this, keeping the feature set in line with my minimum requirements? If so, any links to resources will be greatly appreciated.

It is worth noting that the amount of data in a RichTextBox can be very small; what I was trying to clarify was that the text format really had the greatest impact on performance.

+3
source share
1 answer

. , . , , , (.. , , O (n ^ 2) ). Microsoft ( ), .

+1

Source: https://habr.com/ru/post/1758824/


All Articles