SetLoadingWindow.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Threading;
  3. using System.Windows.Forms;
  4. namespace UAS_MES.PublicForm
  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. 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. e.Cancel=true;
  49. }
  50. }
  51. }
  52. }