Search code examples
c#sharpdx

Exiting the SharpDX RenderLoop


SharpDX has a RenderLoop that runs a given delegate in the render loop:

RenderLoop.Run(m_RenderForm, () =>
{
    // Do stuff here to render things...
}

What I need to do is exit the render loop somehow.

RenderLoop.Run(m_RenderForm, () =>
{
    if (DoINeedToQuit() == true)
    {
        // What do I put here?
    }
}

I can't just return, because that only ends the current loop iteration.


Solution

  • You'd have to exit the application (Application.Exit).

    Alternatively, you can do the job you want to do outside of the loop, inside the loop.