

Look into the FileStream class to read 16 bytes at a time. Read your file 16 bytes at a time comment), this also eliminates the need for your _sub_array().So let's address these potential problems: I consider these to be memory problems because we don't know when the Garbage Collector will clean up the memory. You call String.Replace() repeatedly (See bullet 2).


So yeah, do switch to a StringBuilder object as well.

Strings are immutable, so each time you concatenate to the string, internally what's happening is that the whole string is being scrapped and a new one is being made with the additional text. If you get the hang of Threads and Tasks (which are different inside the machine but can be manipulated by similar developer tools) you will never want to render to the UI from the main thread again.ĮDIT: I left the string from your code as it was, but I agree with the comment suggesting StringBuilder instead. This may seem intimidating at first if you have never done it, but trust me. This will stop the data processing from "gumming up" the UI responsiveness. BeginInvoke doesn't access the control directly, so you can use it from the data processing thread to get text written to the control. Only the thread that made the control is allowed to access it directly. This is necessary when you run the data processing on a separate thread because if you try to access the textbox directly with that thread, Windows will complain about a cross-thread call. Also note the BeginInvoke with the richTextBox.Text work in a lambda expression. You'll need to add "using System.Threading" to get access to threads. Private void button1_Click(object sender, EventArgs e) So using your code snippet, make it look more like this: data. You could also use tasks instead of threads, either way. You are wiser to use a separate thread for the hex work and let the main thread focus on keeping your UI operating smoothly. However, if you need the entire file in memory at once, I think your main problem might be the "stickiness" that the program will experience while reading and converting data. As has been said in the comments, you should try to avoid reading in the entire file at once.
