Jump to content
  • Advertisement
Sign in to follow this  
BlackJoker

Place message loop inside each window

This topic is 1082 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

Hi,

I am trying to develop my own UI on C# based on native Win32 window and DX and faced with a common issue.

If I create a window in another thread, main message loop will no process messages for that window and it will freeze.

So, obvious solution is: place individual message loop inside each window to make sure that messages will reach each window.

 

But when I tried to implement that, I faced with another problem: window just freezes and not respond to any commands.

 

Does anyone know how to correctly place message loop inside each window that it work as expected?

I will appreciate for any samples taking into account the ?# specific. Currently I am using p/Invoke for marshaling C++ functions.

Share this post


Link to post
Share on other sites
Advertisement
You should not be creating and manipulating windows in multiple threads, you gain absolutely no benefit and simply run into a ton of headaches (as you are discovering).

Pick one thread to run the UI (likely your main thread which is already running a message pump) and issue messages to it when you want it to do something either through your own message passing system, or the PostMessage Win32 function.

Also, why are you using Win32 in C#? You would save yourself a lot of time and pain by using one of the native .NET UI systems like Forms or WPF.

Share this post


Link to post
Share on other sites

I dont want to be dependent from WInForms or WPF as they has their own bugs and I want to make my own UI Control system from scratch.

 

 

 

Pick one thread to run the UI (likely your main thread which is already running a message pump) and issue messages to it when you want it to do something either through your own message passing system, or the PostMessage Win32 function.

 

You mean that I must not create windows in other threads than main? Or just post messages to the threads, where windows was created?

Share this post


Link to post
Share on other sites

 

 

So you'd rather introduce a huge number of your own bugs rather than use a system that has been heavily tested by a huge corporation and thousands of developers for years?

Yeah, you right.

Actually I have not so much from Win32 side. The more work I have from architecture point, but thanks for your help anyway.

 

Will reinvent the wheel further :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!