Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

hellfire

Help with Threads and Processes

This topic is 5843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a app that generates terrain data and than using directx puts the 3D terrain on a window. I am using MFC to create all my windows. While the terrain infomation is being created and loaded I have a dialog window pop up with a progress bar showing how how much of the loading is down. I do all the generating and loading in for loops. While I am running the functions with the for loops in them all other procces are blocked. All WM_Messeges are blocked until the loading is done. I have tested this many times. I need a way to force the window messages throw, because while I am running the for loops, I can''t move the windows or close them or max or min them. I have used breaks and I know that all the window messeges are just put in the queue and handled after the for loop finishes. Even if there are messege handlers in the for loop. I was thinking using threads would be the answer, but all I really what is for the messeges to be handled while I am running the for loop.

Share this post


Link to post
Share on other sites
Advertisement
You could use threads, but it might be overkill from what you are saying.

If you just want messages to be processed while you are stuck in a for loop, you could write a function to handle that. We have something like that called "Defer()" which basically looks like this:

void Defer(void)
{
MSG msg;
while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

So whenever we need to have messages processed during a piece of code that normally takes a long time to execute (such as a large for loop that generates terrain), we just insert this where apropriate. Its not the solution for everything but it might be what you need. Give it a try.

Share this post


Link to post
Share on other sites
I have tired that problem and it works, sort of. The problem with that is solution is that it takes too long for the message to be handled. I hit the maxize button on the window and it 5 seconds later the window maxizes. I guess what I am saying is that I need way to interrupt the loop, whenever a windows messege goes into the queue, than handle the messege and than go back to the loop.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!