I have an application that is going to be loading in about 30,000 files (very very small ones). These will be saved into memory (predicting about ~30MB of memory needed), and right now I just have them loaded in one at a time..I'll find a better algorithm for loading in later.

My question here is is how do I allow my application to fully load and then load in the files in the background? I have tried using a seperate thread but it throws "Cross-thread exception" errors at me when I try to have it update with a loading bar on the main form.

Any suggestions would be great. I'd really like to have the main form functioning fine to allow the user to do other things while it is loading (only about 1-2 minute load time) instead of them having to sit there with nothing on the screen wondering why the application "isn't working".


Check out ther backgroundworker object. It allows you to report progress back to the main form to update your progress bar and reports its completion.
Alternatively, if you use a regular thread you will need to use invoke to access members of the UI thread.