Sign in to follow this  

[.net] Multithreaded Resource Loader...

Recommended Posts

Hey guys, My game needs to parse some XML files and load a bunch of textures before running. It's starting to take a noticeable amount of time, and I would like to get the player started going through the game menus while the rest of the stuff is loading in the background. I know synchronization issues can be thorny, so the way I would like to do it is to run the start up form (the one with the options to fill out) in a different thread. How do I -------- Start a new thread, have it do a form.Show and then wait for the form to close to terminate? I guess I don't understand how to make the worker thread handle the form's message hander. I want to be able to start a worker thread that only terminates when the player is done selecting options. Then I can just have the rest of the game do a Thread.Join once it is done loading all the resources.

Share this post

Link to post
Share on other sites
A form has to be 'in' one thread, i.e. its event handlers get called on the thread which created it.

You can probably do something like this in the thread run function for your secondary thread:
void ThreadRun(){
StartupForm f = new StartupForm(whatever);

... and then set up event handlers on the form as usual (probably using your GUI design tool). I don't think that'll cause the app to exit when the option form is closed (there'll still be a message loop on the main thread). But I haven't tried it.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this