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();
                    }));
                }
            }
        }
    }
    

      

  • 相关阅读:
    260.java风格简介
    259.Java标识符和注释
    258.计算机网络的性能指标
    257.计算机网络的组成
    256.常见的网络拓扑结构
    HDFS文件的读写流程入门学习
    Servlet入门
    Linux下扩展根分区-非LVM
    Tomcat基本使用
    JDBC入门
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/7866445.html
Copyright © 2011-2022 走看看