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.

Separate thread for PlaneFinding PlaceOnPlane HoloToolKit

Can someone explain how to use ThreadPool.QueueUserWorkitem or how to call PlaneFinding on a separate thread not in Update

    // Now call FindPlanes().  NOTE: In a real application, this MUST be executed on a
    // background thread (i.e.: via ThreadPool.QueueUserWorkItem) so that it doesn't stall the
    // rendering thread while running plane finding.  Maintaining a solid 60fps is crucial
    // to a good user experience.
    planes = (VisualizeSubPlanes) ?
Tagged:

Answers

  • In our Spatial Mapping course, we use a combination of Task.Run and Unity's Coroutine to run PlaneFinding in the background. Here is the code snippet from SurfaceMeshesToPlanes that calls it:

    #if !UNITY_EDITOR 
    // When not in the unity editor we can use a cool background task to help manage FindPlanes(). 
    Task<BoundedPlane[]> planeTask = Task.Run(() => PlaneFinding.FindPlanes(meshData, snapToGravityThreshold, MinArea)); 
    
    while (planeTask.IsCompleted == false) 
    { 
        yield return null; 
    }
    BoundedPlane[] planes = planeTask.Result; 
    #else 
    // In the unity editor, the task class isn't available, but perf is usually good, so we'll just wait for FindPlanes to complete. 
    BoundedPlane[] planes = PlaneFinding.FindPlanes(meshData, snapToGravityThreshold, MinArea); 
    #endif 
    
  • is that the same as

    ThreadPool.QueueUserWorkItem

    ?

    or are there other recommended ways to do multithread

    @ahillier said:
    In our Spatial Mapping course, we use a combination of Task.Run and Unity's Coroutine to run PlaneFinding in the background. Here is the code snippet from SurfaceMeshesToPlanes that calls it:

    #if !UNITY_EDITOR 
    // When not in the unity editor we can use a cool background task to help manage FindPlanes(). 
    Task<BoundedPlane[]> planeTask = Task.Run(() => PlaneFinding.FindPlanes(meshData, snapToGravityThreshold, MinArea)); 
                  
    while (planeTask.IsCompleted == false) 
    { 
        yield return null; 
    }
    BoundedPlane[] planes = planeTask.Result; 
    #else 
    // In the unity editor, the task class isn't available, but perf is usually good, so we'll just wait for FindPlanes to complete. 
    BoundedPlane[] planes = PlaneFinding.FindPlanes(meshData, snapToGravityThreshold, MinArea); 
    #endif 
    
Sign In or Register to comment.