Running a WPF control in another thread

后端 未结 2 1771
温柔的废话
温柔的废话 2020-12-08 03:31

I am using a visual control in my project that is from a library that I do not have the source to.
It takes too long to update (200ms, roughly) for good UI responsivenes

2条回答
  •  甜味超标
    2020-12-08 03:46

    I've been looking into this as well, and the most relevant information I could find was in this blog post (however I have not tested it yet):

    http://blogs.msdn.com/b/dwayneneed/archive/2007/04/26/multithreaded-ui-hostvisual.aspx

    it creates a HostVisual on the UI thread, then spins up a background thread, creates a MediaElement, puts it inside a VisualTarget (which points back to the HostVisual), and puts it all inside our hacky VisualTargetPresentationSource.

    The problem with this method is that apparently the user won't be able to interact with the controls that are running in the new thread.

提交回复
热议问题