日期:2014-05-18  浏览次数:20804 次

WinForm下Splash的问题
C# code

namespace ShiftConnect.UI
{
    public partial class Mainform : Form
    {
        public Mainform()
        {
            //thread to show splash screen
            Thread threadLoading = new Thread(new ThreadStart(splashscreen));
            threadLoading.Name = "Splash UI";
            threadLoading.Priority = ThreadPriority.Normal;//定义级别
            threadLoading.IsBackground = true;//定义是否后台线程
            threadLoading.Start();//启动线程
            InitializeComponent();
            
        }
        /// <summary>
        /// 窗口创建事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Mainform_Load(object sender, EventArgs e)
        {
            if (AccessHelp.conntrue() == false)
            {
                MessageBox.Show("数据库连接失败!\r\n请查看数据库是否存在或者连接字符串是否正确", "提示");
                this.Close();
            }
            else
            {
                    SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取WheelChange信息......"; }));
                    Thread.Sleep(1000);
                    Form_load();//载入CO2和wheelchange信息
                    SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取交接事项信息......"; }));
                    Thread.Sleep(1000);
                    ShiftconnRefush();//载入交接事项
                    SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取B/L设备信息......"; }));
                    Thread.Sleep(1000);
                    equipinfor();//载入设备信息
                    SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取设备菜单......"; }));
                    Thread.Sleep(1000);
                    EvelauteMenu();//为cmb_pcLine装载下拉菜单
                    SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.lable1.Text = "正在读取CO2库存信息......"; }));
                    Thread.Sleep(1000);
                    co2load();//装载co2设备菜单
                    Thread.Sleep(3000);
                    SplashForm.Invoke(new MethodInvoker(delegate { SplashForm.Dispose(); }));
                    this.WindowState = FormWindowState.Normal;
               
            }
        }
        /// <summary>
        /// 定义splash screen
        /// </summary>
        public static void splashscreen()
        {
            SplashForm = new Login();
            Application.Run(SplashForm);
        }

        public static  Login SplashForm
        {
            get;
            set;
        }


如上面的代码:是winform窗口的一个splash screen
并且本机上调试已经通过了(win7)
splash screen也能够实时的显示载入进度
但是为什么把exe文件发给别的电脑(xp)
打开程序后,程序只是显示一下就会自动关闭呢  
很纠结,求教。。。

------解决方案--------------------
你这个多线程写法很奇怪。
------解决方案--------------------
你代码读写硬件信息的时候是不是调用别人的dll了,看dll考没考过去,如果考过去啦,再看看你调用的dll是不是支持xp
以上为猜测,主要你还想听清你说的你的一闪而过,进去程序啦没有。