zoukankan      html  css  js  c++  java
  • 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();
                    }));
                }
            }
        }
    }
    

      

  • 相关阅读:
    Python Day23
    Python Day22
    Python Day21
    Python Day20
    Python Day19
    Python Day18
    Python Day17
    python全栈开发 * 18 面向对象知识点汇总 * 180530
    python全栈开发 * 15知识点汇总 * 180621
    python全栈开发 * 14 知识点汇总 * 180530
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/7866445.html
Copyright © 2011-2022 走看看