Jump to content
  • Advertisement
Sign in to follow this  
DrGUI

[.net] GDI+ drawing on form from non-main thread?

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

Hey Do you think it's alright to draw on the form with GDI+ from another thread while loading textures, effects and suchlike with DirectX in the main thread? I would just try it if I hadn't heard talk on the forums of Controls not liking being accessed from more than one thread. I would of course terminate the GDI+ thread before presenting with DirectX. Cheers

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the suggestion capn.

So would it be alright to use the Device from another thread as long as both threads don't try to use it at once? (I don't want a multithreaded device)

Share this post


Link to post
Share on other sites
Quote:
Original post by DrGUI
Thanks for the suggestion capn.

So would it be alright to use the Device from another thread as long as both threads don't try to use it at once? (I don't want a multithreaded device)


mutlithreaded versions of objects in any language I've encountered are just objects that handle their own mutual exclusion. So, as long as you handle the mutual exclusion of the device properly on your own, you won't have to use a multithreaded device.

Share this post


Link to post
Share on other sites
Groovy, thanks for that.
Why does Windows Forms have that problem then?

Raties for you... EDIT: wow you set up the 3hr game contest!! go you!!

Share this post


Link to post
Share on other sites
Quote:
Original post by DrGUI
Groovy, thanks for that.
Why does Windows Forms have that problem then?

Raties for you... EDIT: wow you set up the 3hr game contest!! go you!!

I have never noticed anything with it, I often do GDI+ calls in a seperate thread. However, I think the GDI rendering system is tightly coupled with the event system, so if you are not careful and starve the event thread, then you'll cause problems for GDI. You'll have rendering issues if you are running a ST app with a while loop rendering to GDI without a call to Application.DoEvents(), so I'm assuming it's something similar.

and yeah, the 3H-GDC is mine :)

Share this post


Link to post
Share on other sites
Coolay...

Seems best to load DirectX resources in the non-main thread then, to avoid trouble with the event system.

However, (although I'll obviously try to avoid this), what happens if exceptions are thrown from the other thread?

Cheers

Share this post


Link to post
Share on other sites
Quote:
Original post by DrGUI
Coolay...

Seems best to load DirectX resources in the non-main thread then, to avoid trouble with the event system.

However, (although I'll obviously try to avoid this), what happens if exceptions are thrown from the other thread?

Cheers


uh, it crashes the program if you don't catch it.

Share this post


Link to post
Share on other sites
Quote:
Original post by capn_midnight
uh, it crashes the program if you don't catch it.


Hmmm...how would I catch it in the main thread so I could shut the app down?

A perfect example of why literally 80% of code is error handling...

Maybe better to have GDI in the other thread because it's less likely to fail as I'd just be drawing images and possibly a progress bar and I guess I could always ignore exceptions on that thread.

Now school work's back to normal with the Jan modules being over for me (finally) I'll only be getting a few hours programming a week...I might get round to this in a couple of months :(

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!