开发者

Make an single instance app and showing the MainWindow when another instance is launched in VB.NET with WPF

开发者 https://www.devze.com 2023-04-01 20:09 出处:网络
I am looking for a way to make my app running in a single instance mode and showing the MainWindow of the first instance when another instance is launched.

I am looking for a way to make my app running in a single instance mode and showing the MainWindow of the first instance when another instance is launched. I do a quick search on the internet but I did'nt find anything to open the MainWindow of the first instance or it was for Windows Form not for WPF.

I am working in VB.Net with Framework 4 and WPF.

Thanks开发者_StackOverflow中文版


I wrote up an article for Winforms a while back at http://www.thinqlinq.com/Post.aspx/Title/Single-Instance-Winform-Issue. With winforms you can use the MyApplication_StartupNextInstance event handler to intercept subsequent launch requests and redirect them (navigating back to the MainWindow?) Unfortunately, I don't see that StartupNextInstance is still available with WPF. Maybe the pre 2.0 sample I posted at http://web.archive.org/web/20060528010613/http://www.avbsg.net/Uploads/SingleInstanceVB.zip can give you an idea of how to do this with WPF. My blog post walks through the general steps that I used.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号