【问题标题】:How to prevent open my application more than one time? [duplicate]如何防止多次打开我的应用程序? [复制]
【发布时间】:2012-03-15 12:26:35
【问题描述】:

可能重复:
What is the correct way to create a single instance application?

如何定义我的应用程序在反复单击其 exe 文件后仅打开一次?

【问题讨论】:

    标签: c# winforms single-instance


    【解决方案1】:

    Single Instance Applications 的 Stack Overflow 上有几个相关问题:

    这个好像最合适:What is the correct way to create a single-instance application?

    【讨论】:

      【解决方案2】:

      我总是在应用程序的入口点这样做:

      bool onlyInstance = false;
      
      Mutex m = new Mutex(true, "MyUniqueMutextName", out onlyInstance);
      if (!onlyInstance)
      {
          return;
      }
      
      GC.KeepAlive(m);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-02
        相关资源
        最近更新 更多