c# - Is there any way to use an object across two STA threads in WPF? -


OK, before anyone starts, I'm clear ...

I Custom control, in this case, the telemark's Radpen when you deserialize these straps they come through a callback method, and thus, all are owned / deserialized by a thread, and they can not be copied or copied deep etc. So there are some big limitations I am trying to work with. This is bad because, I want to add content to each panel, but I want to do all those work within the UI thread. For example, I want to add a list to a panel and update it with millions of records etc. But if I update a pane, the UI thread will lock for all pan.

I need this to be the contents of this object in a separate thread, but the problem is, when I try to set the content, the obvious point is that the object is similar to the owner of my pane Thread is not owned by:

  myRadPane.Content = myGrid;  

My grid has a different thread than my merideme, so it does not want to set the content, whether WPF has any way around this problem or the UI Is there a way to allow "sharing" in thread?

EDIT: Please note, I have full information about how dispatches work, and when using my application whenever the main UI thread needs to be updated for a pane, In this case, while using at least the dispatches, UI threads fall under heavy loads.

You can copy WPF controls.

Call it in your Creator thread:

  Public string code WPPControl & lt; T & gt; (T source) {string childXaml = XamlWriter.Save (source); Var stringReader = new string reader (childXaml); Return string reader. Toasting (); }  

Transfer your dispatcher / STA thread to your own and call:

  Public T Recactor WPCCRTCLL & lt; T & gt; (String source) {var xmlReader = XmlReader (source); Var cloning group = (t) xml rider. Lod (xmlReader); Return baby cloned; }  

Then create your object in a separate thread, then copy the control and all its binding act and use it to display the output.

Imported Only this XML description


Comments