WPF Enforce only ONE instance of application

后端 未结 5 513
温柔的废话
温柔的废话 2021-01-30 17:12

How do I allow only one instance of a WPF application to run?

Thanks.

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 17:43

    Check out this solution: Allowing only one instance of a WPF application to execute

    This not only enforces one instance of an application, but it also gives your current application focus when an additional instance of an application is ran. My mutex solution to restricting one instance is actually different from the above link, but I liked the "focus" element to this solution.

提交回复
热议问题