App.cs 808 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace OneNote2PDF
  7. {
  8. /// <summary>
  9. /// 全局 app 对象
  10. /// </summary>
  11. class App
  12. {
  13. public string inputDir = "";
  14. public string outputDir = "";
  15. private static App app;
  16. private static readonly object locker = new object(); // 对象锁标志
  17. public static App getInstance()
  18. {
  19. if (app == null)
  20. {
  21. lock (locker) //标志对象加锁,多线程内部代码会挂起
  22. {
  23. if (app == null)
  24. {
  25. app = new App();
  26. }
  27. }
  28. }
  29. return app;
  30. }
  31. }
  32. }