using System; using System.Threading; using System.Windows.Forms; namespace UAS_MES.PublicForm { public partial class SetLoadingWindow : CustomControl.BaseForm.BaseForm { Thread LoadingThread; public SetLoadingWindow() { InitializeComponent(); } public SetLoadingWindow(Thread LoadEvent,string Title) { InitializeComponent(); LoadingThread = LoadEvent; Text = Title; } private void SetLoadingWindow_Load(object sender, EventArgs e) { //设置Loading的大小,启动传递过来的进程 loadingCircle1.OuterCircleRadius = 20; loadingCircle1.InnerCircleRadius = 12; loadingCircle1.Active = true; LoadingThread.Start(); //在本窗体新建一个进程用来判断传递的进程是否执行结束 Thread t1 = new Thread(SetLoadFinish); t1.Start(); } private void SetLoadFinish() { try { while (LoadingThread.IsAlive) { } Close(); } catch (Exception) { return; } } //在进程结束之前不允许此窗体被关闭 private void SetLoadingWindow_FormClosing(object sender, FormClosingEventArgs e) { if (LoadingThread.IsAlive) { e.Cancel=true; } } } }