AppUtil.cs 593 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Windows.Forms;
  3. namespace Update.Util
  4. {
  5. /// <summary>
  6. /// 应用工具
  7. /// </summary>
  8. public static class AppUtil
  9. {
  10. /// <summary>
  11. /// 空闲时执行指定方法
  12. /// </summary>
  13. /// <param name="action">方法</param>
  14. public static void Idle(Action action)
  15. {
  16. EventHandler handler = null;
  17. handler = (sender, e) =>
  18. {
  19. Application.Idle -= handler;
  20. action();
  21. };
  22. Application.Idle += handler;
  23. }
  24. }
  25. }