Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

Asynchronous programming question in holographic app template

Hi,
I have a question about asynchronous programming in holographic app template.
In SpinningCubeRenderer::CreateDeviceDependentResources(), the resources are loaded and created asynchronously. The variable m_loadingComplete is used to denote the resources have been loaded and created as shown below.
// Once the cube is loaded, the object is ready to be rendered.
createCubeTask.then([this] ()
{
m_loadingComplete = true;
});

However, this variable is also accessed in SpinningCubeRenderer::Update(const DX::StepTimer& timer) in the main GUI thread as follows:
// Loading is asynchronous. Resources must be created before they can be updated.
if (!m_loadingComplete)
{
return;
}

I am confused why there is no synchronization for this variable?

Thanks.

YL

Answers

  • AmerAmerAmerAmer ✭✭✭
    edited February 2017

    createCubeTask.then is a two step process. First it executes the createCubeTask on separate thread and when completed it continues to .then() lambda expression which sets the m_loadingComplete to true. Put a debug point there. You'll see it execute once the task is done.

    http://www.redsprocketstudio.com/
    Developer | Check out my new project blog

  • You mean the second task i.e. the lambda expression is executed in the rendering thread, so no need synchronization?

  • AmerAmerAmerAmer ✭✭✭
    edited February 2017
    Yes, the original thread continues.

    http://www.redsprocketstudio.com/
    Developer | Check out my new project blog

Sign In or Register to comment.