I've made MP3 Files on my computer to associate with my media player. So when i double click a MP3 file in the explorer, obviously the media player fires up and plays it.
My problem I can prevent multiple instances popping up, but how can i transfer the file path of the new instance to the instance i am using already
What i want to happen: I double click a song,... and im listening to it I double click another song and the current song should stop and new song should start playback, without popping up a new instance of the application.
I use Mutex to check whether there is already a running instance. To get file path i use Environment.GetCommandLineArgs()
All I need is to pass the file's path to the current instance. How can I do this??
An application instance is a collection of services and service groups that is associated with a top-level consumer. Start by creating an application instance from an application template. Then, deploy the application instance and any packages associated with it.
An instance is a single copy of the software running on a single physical or virtual server. If you run two copies of the software on the same physical or virtual server, that counts as two instances.
Within a single installed application server instance you can offer companies or individuals domain names, IP Addresses, and some administration capabilities. For the users, it is almost as if they have their own web server, without the hardware and basic server maintenance.
Essentially you will have to build this into your application.
When a user clicks a second song, you would have to have some way for the current instance to kill the previous instance of your application or send it a message.
These seems a little dirty to me.
I think a clean approach would be to write a small app_booter.exe
that is associated with your media files. When a media file is clicked, it starts this _app_booter_ which :
To send your application data from this other exe you could take a look at IPC: Interprocess communication for Windows in C# (.NET 2.0)
I think the WM_COPYDATA
approach mentioned in the above post, or a tcp socket would suffice since your data is pretty simple, just a file path and maybe a command.
I think keeping two separate exes will be easier and cleaner than building your app to talk to its previous instance.
I think you are looking for this http://wpfinstanceawareapp.codeplex.com/
Provides the functionality for a single instance application that can pass the command line arguments to the first instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With