I built a media player, that media player is associated with several media file types.
Every time that a user opens a media file, I check if my player is open.
I managed to prevent opening two instances but I want to pass the file path to the already opened instance.
I am using mutex to prevent opening and I have been trying to use SendMessage to pass strings.
What is the best way to do so?
Asked
Active
Viewed 186 times
0

Yinon Eliraz
- 317
- 1
- 6
- 22
-
There are a whole raft of technologies available to you including WCF, MSMQ and Remoting. – Liath May 30 '14 at 14:42
2 Answers
0
I think a good way is to create a WCF service into your media player. You will can communicate easily with it. See the ServiceHost class

Silvinus
- 1,445
- 8
- 16
0
Try named pipes, i.e.NamedPipeServerStream
& NamedPipeClientStream
. Some general overview is avaibale here as well, although in your case basic write-to-temp-lock-file/read-from-temp-lock-file might not be such a bad idea.

Ilya Kozhevnikov
- 10,242
- 4
- 40
- 70
-
-
@user1689604 What's FW2? See the edited, would a temp file suffice? – Ilya Kozhevnikov May 30 '14 at 14:49
-
framework2. writing to a temp file wont suffice: first, how do i know when to read from it? second, its really messy. – Yinon Eliraz May 30 '14 at 14:57
-
Lock files suffice for Tomcat, TeamCity, Vim, etc. I don't think your media player is more special than that. Plus names pipes are not .NET 3.5, the C# wraper is, you can do a bit of `CreateNamedPipe` PInvoke magic, see the 'here' link example. – Ilya Kozhevnikov May 30 '14 at 15:03
-
It still doesn't answer the first question- I still need to know when to read it. – Yinon Eliraz May 30 '14 at 15:05
-
Write on `Mutex` failure, read on `FileSystemWatcher` event? I'd still go for some named pipe pinvoke though. – Ilya Kozhevnikov May 30 '14 at 15:09
-
When i automate the sending process, it doesnt work. any idea why? – Yinon Eliraz May 30 '14 at 20:53
-
Not sure what is 'automate the sending process', are you trying the PInvoked named pipe? Does the sample client/server from wyDay's zip work? Anyway, try asking a new question -- comments are not meant as a chat. – Ilya Kozhevnikov Jun 02 '14 at 09:16