WaitingForm.cs 799 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace WWPipeLine.MapBasic
  11. {
  12. public partial class WaitingForm : Form
  13. {
  14. public WaitingForm(EventHandler<EventArgs> Method, string msg)
  15. {
  16. InitializeComponent();
  17. if (!string.IsNullOrEmpty(msg)) uiLineMsg.Text = msg;
  18. _Method = Method;
  19. }
  20. private EventHandler<EventArgs> _Method;
  21. private IAsyncResult asyncResult;
  22. private void WaitingForm_Shown(object sender, EventArgs e)
  23. {
  24. asyncResult = _Method.BeginInvoke(null, null, null, null);
  25. }
  26. private void timerS_Tick(object sender, EventArgs e)
  27. {
  28. if (asyncResult.IsCompleted)
  29. this.Close();
  30. }
  31. }
  32. }