WPF Enforce only ONE instance of application

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

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

Thanks.

5条回答
  •  攒了一身酷
    2021-01-30 17:39

    User sobelito linked this post, which has the following update. What it says is that for an updated resource you should use Windows 7 Taskbar Single Instance, which if you look into the source will allow you to do what you need.

    You can use the SingleInstance c# project. It also contains samples for both WinForms and WPF.

    Note that it's also released under the Apache 2.0 license, unlike Arik's Poznanski post in the Microsoft Blog, which is (IANAL, AFAIK) not commercially available.

提交回复
热议问题