• WaitingFormHelper


    using Lba_Ciac;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace Lbb.Cx.Ciac.Utility
    {
        public class WaitingFormHelper
        {
            private Loading waitingForm = null;
    
            private Action _method = null;
    
            private WaitingFormHelper(Action method, string message)
            {
                this._method = method;
                this.waitingForm = new Loading();
                this.waitingForm.Text = message;
                this.waitingForm.StartPosition = FormStartPosition.CenterParent;
                this.waitingForm.Shown += new EventHandler(this.waitingForm_Shown);
            }
            public static void ShowWaitingForm(Action method, string message)
            {
                WaitingFormHelper waitingFormHelper = new WaitingFormHelper(method, message);
                waitingFormHelper.waitingForm.ShowDialog();
            }
    
            private void waitingForm_Shown(object sender, EventArgs e)
            {
                try
                {
                    this._method.BeginInvoke(new AsyncCallback(this.callBack), null);
                }
                catch (System.ObjectDisposedException)
                {
                    return;//如果主界面已经退出了,那线程也退出好了。
                }
            }
    
            private void callBack(IAsyncResult ar)
            {
                if (this.waitingForm != null && !this.waitingForm.IsDisposed)
                {
                    this.waitingForm.Invoke(new Action(delegate
                    {
                        this.waitingForm.Close();
                    }));
                }
            }
        }
    }
    

      

  • 相关阅读:
    JAVA实现文件遍历
    关于java的JIT知识
    经典的01背包问题
    文件遍历
    [算法之动态规划] 基本思想
    软件设计经典书籍推荐
    C++ 学习之函数重载、基于const的重载
    tomcat调用axis服务时出现 java.lang.InvocationException解决方案
    文件上传的原理
    文件上传的原理
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/7866445.html
Copyright © 2020-2023  润新知