locked
Show progress ring during rendering process

    Question

  • I'm trying to show a progress ring during the rendering, because this may take several seconds. The app doesn't respond in that time, so i tried to set the activity of the progress ring defined in the xaml markup to true at the beginning of the OnRendering-method (defined in the Direct2D + Xaml template which i'm using) and set it to false at the end, but the app doesn't show any response. When the ring is only activated, it becomes active immediately at the beginning. What am i doing wrong? Furthermore the app-requirements say that a progress ring should only be shown when the latency is 500ms or more. How is that realisable ? Any suggestions on howto solve my problem were helpful. Thanx!

    void DirectXPage::OnRendering(Object^ sender, Object^ args)
    {
    	if (m_renderNeeded)
    	{
    		loadingRing->IsActive=true;
    		m_timer->Update();
    		m_renderer->Update(m_timer->Total, m_timer->Delta);
    		m_renderer->Render();
    		m_renderer->Present();
    		m_renderNeeded = false;
    		loadingRing->IsActive=true;
    	}
    }

     
    Monday, April 08, 2013 5:28 PM

Answers

  • Progress should be for things 2 seconds or more.  However if the task is sometimes less than 2 seconds than wait 500 ms before displaying progress per:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh465469.aspx

    Best Wishes - Eric


    This posting is provided "AS IS" with no warranties, and confers no rights.


    Monday, April 08, 2013 11:56 PM
    Moderator
  • Your calls to m_renderer->Update, m_renderer->Render, and m_renderer->Present all run on the UI thread. As a result you are tying up the UI thread, preventing anything else (such as the XAML progress ring) from being displayed or updated until your m_renderer calls complete.

    If you have some long running rendering code, you'll need to figure out a way to break up the tasks into shorter bits that can be done over the course of several calls to OnRendering or else you'll need to carefully design your code such that you can run the long running parts on a background thread and only when those are done come back and perform the actual rendering on the UI thread. The second option assumes that what's taking long isn't the rendering itself but is just some preparation for the drawing.

    There is no boilerplate answer since it's a (potentially) complex design and code structure question that depends very much on the specific details of what you are trying to do.

    Await won't do any good since this is C++, not C# or VB. But you might want to investigate async programming using the parallel patterns library (PPL). The Hilo project from the patterns & practices team is really helpful for understanding PPL tasks and C++ async programming in Windows Store apps: http://msdn.microsoft.com/en-us/library/windows/apps/jj160321.aspx .


    Visual C++ MVP | Website | Blog | @mikebmcl | Windows Store DirectX Game Template

    Tuesday, April 09, 2013 5:41 AM

All replies

  • Progress should be for things 2 seconds or more.  However if the task is sometimes less than 2 seconds than wait 500 ms before displaying progress per:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh465469.aspx

    Best Wishes - Eric


    This posting is provided "AS IS" with no warranties, and confers no rights.


    Monday, April 08, 2013 11:56 PM
    Moderator
  • Your calls to m_renderer->Update, m_renderer->Render, and m_renderer->Present all run on the UI thread. As a result you are tying up the UI thread, preventing anything else (such as the XAML progress ring) from being displayed or updated until your m_renderer calls complete.

    If you have some long running rendering code, you'll need to figure out a way to break up the tasks into shorter bits that can be done over the course of several calls to OnRendering or else you'll need to carefully design your code such that you can run the long running parts on a background thread and only when those are done come back and perform the actual rendering on the UI thread. The second option assumes that what's taking long isn't the rendering itself but is just some preparation for the drawing.

    There is no boilerplate answer since it's a (potentially) complex design and code structure question that depends very much on the specific details of what you are trying to do.

    Await won't do any good since this is C++, not C# or VB. But you might want to investigate async programming using the parallel patterns library (PPL). The Hilo project from the patterns & practices team is really helpful for understanding PPL tasks and C++ async programming in Windows Store apps: http://msdn.microsoft.com/en-us/library/windows/apps/jj160321.aspx .


    Visual C++ MVP | Website | Blog | @mikebmcl | Windows Store DirectX Game Template

    Tuesday, April 09, 2013 5:41 AM
  • Thank You Mike!

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, April 09, 2013 5:33 PM
    Moderator