I have an existing program that I have to work around. It provides a fairly decent plugin architecture, but I’ve run into a problem. I need to create a command-line plugin that will check if the program is already running and then pass the command-line parameters to the existing instance.
Is this possible using a plugin? Would best practice in a situation like this be to use the messaging system?
For the scenario you describe, I have used a WCF service hosted over the net.pipe protocol. Basically, I have a contract that defines an endpoint that can receive the information that you would provide as command-line arguments.
When your process starts, it first attempts to contact this service. If the service is available, that means an existing process is already up and running. In that case, open a channel to the process, send the data to it, and then exit. If the service is not available, start the service.