How do I close the window other than in direct response to user input? #1506
-
Sometimes after the user opts to close the game you need to keep the render loop running for a little while. The game might be in the process of auto-saving, disconnecting from a server gracefully, or playing a bit of animation. It doesn't currently seem possible to do this with Silk.NET. Run()'s source code for reference: DoEvents seems used for event-driven input. DoUpdate and DoRender both set a variable which is used to throw in Reset (called by Close) so I can't poll in there to see whether these background tasks are done and I can close the window: (I am guessing that calling Close() from another thread is a Very Bad Idea). |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
this seems more engine structure related than Silk specific, you should see if your code already has a way to do the logic of "wait to run some function", if so i dont see why that cant be done here, you dont need to hook into the internals of Silk |
Beta Was this translation helpful? Give feedback.
-
I'm confused, the problem is that Silk throws if I call window.Close anywhere but an input handler. This appears to be by design but is very limiting. |
Beta Was this translation helpful? Give feedback.
-
Ah so I think I've gotten to the bottom of what's going on here. DoRender/DoUpdate/etc. all set _inRenderLoop but don't un-set it in the event of an exception being thrown. That means that the enclosing Thanks |
Beta Was this translation helpful? Give feedback.
Ah so I think I've gotten to the bottom of what's going on here.
DoRender/DoUpdate/etc. all set _inRenderLoop but don't un-set it in the event of an exception being thrown.
That means that the enclosing
using
statement then disposes the window with the flag still set - which in turn calls reset and raises the exception I've seen here.Thanks