WaitForm.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. namespace LYFZ.ComponentLibrary
  7. {
  8. public class WaitForm
  9. {
  10. // private delegate object someMethodDelegate(object someArg);
  11. private LYFZ.ComponentLibrary.FrmLoadHandling fWait;
  12. // private IAsyncResult ir;
  13. // someMethodDelegate sd;
  14. private object someLongTimeMethod(object someArg)
  15. {
  16. return someArg;
  17. }
  18. public void ShowForm(IWin32Window owner)
  19. {
  20. try
  21. {
  22. System.Threading.Thread.Sleep(1);
  23. // System.IO.File.WriteAllText("test.txt", "开始:" + DateTime.Now.ToString("yyyyMMddhhmmssff"));
  24. fWait = new LYFZ.ComponentLibrary.FrmLoadHandling(false);
  25. // sd = new someMethodDelegate(someLongTimeMethod);
  26. // ir = sd.BeginInvoke("等待中...", null, null);
  27. fWait.StartPosition = FormStartPosition.CenterScreen;
  28. fWait.Show(owner);
  29. fWait.Name = "fwit" + DateTime.Now.ToString("yyyyMMddhhmmssff");
  30. Application.DoEvents();
  31. // fWait.Dispose();
  32. }
  33. catch { }
  34. }
  35. public void CloseForm()
  36. {
  37. try
  38. {
  39. System.Threading.Thread.Sleep(15);
  40. // System.IO.File.AppendAllText("test.txt", "\r\n close:"+ DateTime.Now.ToString("yyyyMMddhhmmssff"));
  41. if (fWait != null)
  42. {
  43. fWait.Close();
  44. fWait.Dispose();
  45. // object retValue = sd.EndInvoke(ir);
  46. // fWait = null;
  47. // ir = null;
  48. // sd = null;
  49. }
  50. }
  51. catch { }
  52. }
  53. }
  54. }