I have a C# Windows Forms application that is manually started and then mostly runs in the background. In my registry, this program is set up to handle a "dstel" url protocol. That is, href="dstel:1234567890"
will successfully open my program.
The issue is that my program needs have only one instance running at any given time. My research suggests that in order to ensure that multiple instances are not operating simultaneously, I should use a mutex (courtesy of How to check if another instance of the application is running).
Assuming that works, I am now left with what to do when someone clicks on my special dstel link in a webpage. What I need is how can I redirect the command line input to method xyz() of my already-running application?
To be clear, I'm envisioning the following events, in order:
- I manually start instance A of my program
- I click on the dstel link
- Instance B of my program starts
- Thanks to the mutex, instance B of my program realizes that instance A is already running
- Instance B passes its command line args to method xyz() of instance A. <<<< My issue
- Instance B exits
I have a few things in mind that might work, most notably either using a helper application or setting up a named pipe via WCF. I am open to any suggestions you may have.
Thanks!