1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Threading;
- using System.Windows.Forms;
- namespace UAS_LabelMachine.PublicForm
- {
- public partial class SetLoadingWindow : Form
- {
- 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()
- {
- while (LoadingThread.IsAlive)
- {
-
- }
- Close();
- }
-
- //在进程结束之前不允许此窗体被关闭
- private void SetLoadingWindow_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (LoadingThread.IsAlive) {
- e.Cancel=true;
- }
- }
- private void CancelThread_Click(object sender, EventArgs e)
- {
- LoadingThread.Abort();
- }
- }
- }
|