SetLoadingWindow.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Threading;
  3. using System.Windows.Forms;
  4. namespace UAS_XmlAnalysor
  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. e.Cancel=true;
  42. }
  43. }
  44. private void CancelThread_Click(object sender, EventArgs e)
  45. {
  46. LoadingThread.Abort();
  47. }
  48. }
  49. }