0

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

Bahaïka
  • 699
  • 1
  • 11
  • 36
  • possible duplicate of [VB.NET: WPF Single Instance](http://stackoverflow.com/questions/5480176/vb-net-wpf-single-instance) – BoltClock Aug 30 '11 at 17:27
  • @BoltClock: Not quit as the main question seems to be about activating the window in the running application. – H.B. Aug 30 '11 at 17:32

1 Answers1

0

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.

Jim Wooley
  • 10,169
  • 1
  • 25
  • 43
  • I've already did it in Windows Forms with the StartupNextInstance handler, but, there's no portage for WPF. – Bahaïka Aug 31 '11 at 08:26