I have a very long string (Copying data to clipboard ~7million characters on average).
I want to get the first 50 characters of my string. I am currently doing that with this:
rtxtbxClipboard.Text = Clipboard.GetText().Substring(0, 50);
The textbox populates with the substring in a couple seconds, but then the program goes unresponsive for 30-60 seconds.
My understanding of that line of code, is populating the Text field value is the very last thing it's supposd to do, presumably meaning it has completely finished reading the clipboard string, and pulling out the substring.
If that is true, why is the application freezing/going unresponsive?
I know it's related to the length of the string being read, as shorter strings don't have the issue.
If there's a better/more efficient approach to obtaining substrings from long strings, please let me know.