SetLoadingWindow.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Threading;
  3. using System.Windows.Forms;
  4. namespace UAS_AutoPass
  5. {
  6. public partial class SetLoadingWindow : Form
  7. {
  8. Thread LoadingThread;
  9. public SetLoadingWindow()
  10. {
  11. InitializeComponent();
  12. }
  13. public SetLoadingWindow(Thread LoadEvent, string Title)
  14. {
  15. InitializeComponent();
  16. LoadingThread = LoadEvent;
  17. Text = Title;
  18. }
  19. private void SetLoadingWindow_Load(object sender, EventArgs e)
  20. {
  21. //设置Loading的大小,启动传递过来的进程
  22. loadingCircle1.OuterCircleRadius = 20;
  23. loadingCircle1.InnerCircleRadius = 12;
  24. loadingCircle1.Active = true;
  25. LoadingThread.Start();
  26. //在本窗体新建一个进程用来判断传递的进程是否执行结束
  27. Thread t1 = new Thread(SetLoadFinish);
  28. t1.Start();
  29. }
  30. private void SetLoadFinish()
  31. {
  32. while (LoadingThread.IsAlive)
  33. {
  34. }
  35. Close();
  36. }
  37. //在进程结束之前不允许此窗体被关闭
  38. private void SetLoadingWindow_FormClosing(object sender, FormClosingEventArgs e)
  39. {
  40. if (LoadingThread.IsAlive)
  41. {
  42. e.Cancel = true;
  43. }
  44. }
  45. private void CancelThread_Click(object sender, EventArgs e)
  46. {
  47. LoadingThread.Abort();
  48. }
  49. }
  50. }