Hello, you guys!
So, I have an UWP app that contains a RichEditBox component. I've noticed that there's a critical performance decrease every time I open large text files. The app seem to be working more or less fine if the file is less than 10 Mb, but if the file is larger, then the app becomes extremely slow. Not only during the opening of the file, but even later. If the file is about 50 Mb, believe it or not, but the opening takes about a minute on my machine! It's just not possible to work with the file even after you opened it, because the entire app just pretty much freezes and sometimes even crashes. And let's be honest, 10 Mb or even 50 Mb is not that much. It's not supposed to cause such serious performance issue that affects the whole app. I know there are some limitations with certain components. I know that RichEditBox of a Win32 app is also limited to work with the files less than 1 Gb (some sources claim that performance issues start to occur from 512 Mb files). I get it, there are some limitations and that's understandable, but Win32 apps are able to deal with large files of hundreds of Mb of weight, but what about UWP? Why can't I normally work with files of at least 100 Mb? This is unacceptable! So, my question is, whether or not there's a way to fix this issue? And where can I learn about limitations of components?
EDIT:
The code snippet in MainPage.xaml.cs:
private async void FileOpen_Click(object sender, RoutedEventArgs e)
{
// Open a text file.
Windows.Storage.Pickers.FileOpenPicker open = new
Windows.Storage.Pickers.FileOpenPicker();
open.SuggestedStartLocation =
Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
open.FileTypeFilter.Add(".rtf");
Windows.Storage.StorageFile file = await open.PickSingleFileAsync();
if (file != null)
{
Windows.Storage.Streams.IRandomAccessStream randAccStream = await
file.OpenAsync(Windows.Storage.FileAccessMode.Read);
// Load the file into the Document property of the RichEditBox.
ContentPage.current.SetText(randAccStream);
}
}
The code snippet of ContentPage.xaml.cs:
public sealed partial class ContentPage : Page
{
public static ContentPage current { get; set; }
public ContentPage()
{
this.InitializeComponent();
current = this;
}
public void SetText(IRandomAccessStream randAccStream)
{
editor.Document.LoadFromStream(Windows.UI.Text.TextSetOptions.FormatRtf, randAccStream);
}