示例#1
0
        void createChildInNewThread(WrapPanel container, ref RenderElement render)

        {
            HostVisual hostVisual = new HostVisual();

            UIElement content = new VisualHost(hostVisual);

            container.Children.Add(content);

            Thread thread = new Thread(new ThreadStart(() =>
            {
                VisualTarget visualTarget = new VisualTarget(hostVisual);

                var control = new RenderElement();
                if (imageD3D == null)
                {
                    imageD3D = control;
                }
                else
                {
                    imageD3D1 = control;
                }

                control.Arrange(new Rect(new Point(), content.RenderSize));
                control.SetupSurface(RenderType.D3D, rec.Width, rec.Height, FrameFormat.RGB32);
                visualTarget.RootVisual = control;
                device.Start();
                System.Windows.Threading.Dispatcher.Run();
            }));

            thread.SetApartmentState(ApartmentState.STA);
            thread.IsBackground = true;
            thread.Start();
        }