Jump to content
  • Advertisement
Sign in to follow this  
Rooter

Problem with C# Direct3D program not shutting down right...

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

For some reason when the program closes it is still running in the background and I have to manually close it out in the processes. I think I have everything set up right on my end. I'm using the new Visual C# beta with .Net framework 2.0 - any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Yup. I've had the same problem.

First, make sure you Dispose() every resource that is IDisposable before you close (including the device). These resources are not garbage collected in a timely fashion like what you're used to.

Second -- and more importantly -- be sure to set the static property "Device.IsUsingEventHandlers" to "false" by default. Only set it to true when you are attaching something to a Direct3D event (like OnLost(), OnDispose(), etc.) and then immediately set it to false again. The reason why is that C#.Net will automatically hook every object you create events. Many of them. When you exit, there is a huge "unwinding" process that can seem to stall your application.

Share this post


Link to post
Share on other sites
When you want to quit, just call ExitProcess(), and the kernel will clean up all your open handles, allocated memory, etc.

Share this post


Link to post
Share on other sites
Quote:
Original post by The Frugal Gourmet
Yup. I've had the same problem.

First, make sure you Dispose() every resource that is IDisposable before you close (including the device). These resources are not garbage collected in a timely fashion like what you're used to.

Second -- and more importantly -- be sure to set the static property "Device.IsUsingEventHandlers" to "false" by default. Only set it to true when you are attaching something to a Direct3D event (like OnLost(), OnDispose(), etc.) and then immediately set it to false again. The reason why is that C#.Net will automatically hook every object you create events. Many of them. When you exit, there is a huge "unwinding" process that can seem to stall your application.


Yeah, that's exactly it. One thing though - I can't find a Device.IsUsingEventHandlers anywhere - mine just doesn't have it. I'm using the direct x 9.0c summer update sdk I believe. Oh and the ExitProcess() thing didn't work, thanks though.

Share this post


Link to post
Share on other sites
Quote:
Original post by Rooter
Yeah, that's exactly it. One thing though - I can't find a Device.IsUsingEventHandlers anywhere - mine just doesn't have it. I'm using the direct x 9.0c summer update sdk I believe. Oh and the ExitProcess() thing didn't work, thanks though.


It's still in there, because I'm using it too. Make sure you are using the static property. If you use the actual device instance it won't work.

Share this post


Link to post
Share on other sites
Quote:
Original post by The Frugal Gourmet
Quote:
Original post by Rooter
Yeah, that's exactly it. One thing though - I can't find a Device.IsUsingEventHandlers anywhere - mine just doesn't have it. I'm using the direct x 9.0c summer update sdk I believe. Oh and the ExitProcess() thing didn't work, thanks though.


It's still in there, because I'm using it too. Make sure you are using the static property. If you use the actual device instance it won't work.


Thanks, that definitely works. I'm assuming I need to handle some things manually now as I'm having weird behavior with my program on resizing and such, I'll mess around with it. How can I handle the resize/ reset events now manually?

Share this post


Link to post
Share on other sites
Quote:
Original post by Rooter
Thanks, that definitely works. I'm assuming I need to handle some things manually now as I'm having weird behavior with my program on resizing and such, I'll mess around with it. How can I handle the resize/ reset events now manually?


If I want to have an object respond to those events, I usually just set Device.IsUsingEventHandlers to 'true', map it to those events, and then turn it off again.

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!