views:

35

answers:

2

I'm fairly new to VB.NET, and I'm working on a text editor with a tabbed interface. I deal with large text files, so I'm wondering what is the best way to go about this.

Should I have each tab / text document open up in a new thread or a process? I basically want the entire application to always run fast as the text editor is just one part of it. If I have several large text files open I don't want the rest of the application slowing down a bit.

If someone can help shed light on this and maybe point me to a URL with any relevant examples, I'd appreciate it!

+1  A: 

Whether you have 1 or 10 tabs open, you will only be able to type/edit 1 file at a time, the other tabs will just be taking up memory in the data structure you define, so not sure how there would be an impact on performance.

As a side note, if you are doing a large amount of string manipulation use the stringbuilder class, far quicker and memory efficient.

David
+2  A: 

Should I have each tab / text document open up in a new thread or a process?

No. Definitely not a new process. The amount of Win32 to put everything back together will make you hate yourself.

Not a new thread either. The Winforms UI runs in a single dispatch thread. Trying to touch the UI from different threads will make your program explode.

I would recommend simply using the tried, true, and boring background worker approach. This can be used with threads or just using asynchronous IO (.NET handles the threading for you). Depending upon your use case you may want to just lazy-load parts of files, you can use memory mapped or random access files (e.g. only read in a very small part of the file at a time). In any case the "data" should be separate from the visualization of said data.

(Emphasis added to search terms.)

pst
many thanks for the info!
Joe