Program.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using System.Windows.Forms;
  6. namespace HOZProject
  7. {
  8. static class Program
  9. {
  10. /// <summary>
  11. /// 应用程序的主入口点。
  12. /// </summary>
  13. [STAThread]
  14. static void Main()
  15. {
  16. Application.EnableVisualStyles();
  17. Application.SetCompatibleTextRenderingDefault(false);
  18. //Application.Run(new FormUCMain());
  19. //Application.Run(new FormHOZMain());
  20. //Application.Run(new FormMeasureTest());
  21. //Application.Run(new FormUnitControl());
  22. bool createdNew;//返回是否赋予了使用线程的互斥体初始所属权
  23. System.Threading.Mutex instance = new System.Threading.Mutex(true, "MutexName", out createdNew); //同步基元变量
  24. if (createdNew) //赋予了线程初始所属权,也就是首次使用互斥体
  25. {
  26. Application.Run(new FormHOZMain());
  27. instance.ReleaseMutex();
  28. }
  29. else
  30. {
  31. MessageBox.Show("已经启动了一个程序,请先退出!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  32. Application.Exit();
  33. }
  34. }
  35. }
  36. }