C#   一个窗体加载一个窗体显示动画 但是 加载的时候动画卡 为什么 线程有问题么?还是机器配置关系?using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Threading;
using System.Windows.Threading;namespace WpfApplication1
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            
        }
        public void winLoad()
        {
            readXML xml = new readXML();
            DataTable table = xml.ReadMiniDTXml();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                Image user = new Image();
                user.Name = "u" + (i + 1).ToString();
               
                user.Source = new BitmapImage(new Uri(Environment.CurrentDirectory + table.Rows[i]["path1"].ToString().Trim()));                user.Width = 100;
                user.Height = 100;
                this.stackPanel_Image.Children.Add(user);               
            }
        }
        Thread newWindowThread;
        public delegate void AddButtonDelegate();
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //加载进程
            Thread thread = new Thread(DO);
          //  thread.IsBackground = true;
            thread.Start();
            //动画窗体进程
            newWindowThread = new Thread(new ThreadStart(ThreadStartingPoint));
            newWindowThread.SetApartmentState(ApartmentState.STA);
            //newWindowThread.IsBackground = true;
            newWindowThread.Start();
           
        }
        /// <summary>
        /// 开启新窗体 解决因加载,动画卡的问题
        /// </summary>
        private void ThreadStartingPoint()
        {
            Window2 tempWindow = new Window2();
            tempWindow.Show();
            System.Windows.Threading.Dispatcher.Run();
        }
        public void AddImage()
        {
            winLoad();
            
         System.Windows.Application.Current.
        }        void Window1_ContentRendered(object sender, EventArgs e)
        {
            newWindowThread.Abort();  //终止动画窗体进程
        }     
    
        public void DO()
        {            System.Windows.Application.Current.Dispatcher.BeginInvoke(new AddButtonDelegate(AddImage), DispatcherPriority.ContextIdle);        }
    }
}