SetLoadingWindow.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Threading;
  3. using System.Windows.Forms;
  4. namespace UAS_MES_NEW.PublicForm
  5. {
  6. public partial class SetLoadingWindow : CustomControl.BaseForm.BaseForm
  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. try
  33. {
  34. while (LoadingThread.IsAlive)
  35. {
  36. }
  37. Close();
  38. }
  39. catch (Exception)
  40. {
  41. return;
  42. }
  43. }
  44. //在进程结束之前不允许此窗体被关闭
  45. private void SetLoadingWindow_FormClosing(object sender, FormClosingEventArgs e)
  46. {
  47. if (LoadingThread.IsAlive)
  48. {
  49. e.Cancel = true;
  50. }
  51. }
  52. }
  53. }