Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6085591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:39:21+00:00 2026-05-23T11:39:21+00:00

I have several MeshGeometry3D elements that are stored in separate files. For example, somemodel.xml

  • 0

I have several MeshGeometry3D elements that are stored in separate files. For example, somemodel.xml might contain <MeshGeometry3D ... />.

If I load them in the main UI thread, they lock up the UI while they load. So I’ve tried loading them in a separate thread:

ThreadStart threadStart = delegate
{
    var geometry = ConvertXmlFileToMeshGeometry3D(filename);
    viewport2DVisual3D.Dispatcher.BeginInvoke(
        DispatcherPriority.Normal,
        new Action(delegate { viewport2DVisual3D.Geometry = geometry; }));
};
threadStart.BeginInvoke(delegate(IAsyncResult aysncResult) { threadStart.EndInvoke(aysncResult); }, null);

However, this gives an exception on the line viewportVisual.Geometry = geometry;: The calling thread cannot access this object because a different thread owns it.

In other words, the MeshGeometry3D was created on a different thread, so I cannot make it the Viewport2DVisual3D‘s Geometry.

I can’t figure out a way to asynchronously load the MeshGeometry3Ds without them being owned by the wrong thread. Is this just something that is not possible, or is there a way to do it?

Edit: Profiling suggests that about 13% of the time to load a MeshGeometry3D is spent loading the xml element from the file (var element = XElement.Load(filename);), and the rest is spent converting it to a MeshGeometry3D:

return new MeshGeometry3D
{
    Normals = (Vector3DCollection)new Vector3DCollectionConverter().ConvertFromString(element.Attribute("Normals").Value),
    Positions = (Point3DCollection)new Point3DCollectionConverter().ConvertFromString(element.Attribute("Positions").Value),
    TextureCoordinates = (PointCollection)new PointCollectionConverter().ConvertFromString(element.Attribute("TextureCoordinates").Value),
    TriangleIndices = (Int32Collection)new Int32CollectionConverter().ConvertFromString(element.Attribute("TriangleIndices").Value),
};

So it doesn’t look like fetching the XML from disk is the bottleneck here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:39:21+00:00Added an answer on May 23, 2026 at 11:39 am

    Unless you need to modify the model later you can try to Freeze it after it has been loaded, then it can be shared accross threads, see Freezable Objects Overview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have several .NET applications that monitor a directory for new files, using FileSystemWatcher.
I have several large .xml files. I want to parse out the files to
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on
We have several jobs that run concurrently that have to use the same config
I have several old 3.5in floppy disks that I would like to backup. My
I have several applications that are part of a suite of tools that various
I have several log files of events (one event per line). The logs can
I have several LINQ queries that will churn records (up to a million) based
I have several hex-values that I try to write to a file. It seems
I have several questions regarding forms and PHP but if I should put them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.