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

      

  • 相关阅读:
    Delphi中 弹出框的用法
    VC++代码上传到VSS上 注意事项
    VC++ 屏蔽掉警告
    IIS LocalDB 登录失败
    SVN版本回滚实战
    Git常用命令图解
    C# 百度API地址坐标互相转换
    Quartz.NET浅谈一 : 简单Job使用(定时发送QQ邮件)
    发布自己的类库包到Nuget
    C# 常用日期取得
  • 原文地址:https://www.cnblogs.com/XuPengLB/p/7866445.html
Copyright © 2011-2022 走看看