tags:

views:

126

answers:

2

Okay, here's my situation. I have a WPF app that I have created that also includes an application protocol handler so that the app can be opened from links on the web that opens the app with command-line parameters to pre-populate some information. All this is working.

What I would like to accomplish is this. If the user already has the application open, and they click another of these links, it will currently open a new instance of the app. What I would like to be able to is detect if an existing instance of the app running, and if so, send the appopriate values to that application instead of opening a new one.

I know how to check for the existence of an instace (I'm doing it in another application), but I can't figure out how to then send values to that application. Google hasn't been much help, and you guys have always been awesome. Thanks!

James

+1  A: 

There are different solutions for interprocess communication in .NET/WPF. Take a look at this other post: http://stackoverflow.com/questions/953853/simple-ipc-mechanism-for-c-wpf-application-to-implement-app-cli

gustavogb
This example (http://www.flawlesscode.com/post/2008/02/Enforcing-single-instance-with-argument-passing.aspx) seems to be the one to go with, shouldn't have any problem using it with WPF as opposed to WinForms. Marking this as the answer since it was the first response that contained the link. :)
James McConnell
+1  A: 

You should look at http://stackoverflow.com/questions/917883/c-how-to-single-instance-application-that-accepts-new-parameters.

I prefer the IsSingleInstance solution. Just look at Scott Hanselmans solution for IsSingleInstance.

batzen