18

I'm creating a (C#) program that downloads binaries using NZB files, there may only be one instance of my application running at any time.

So when a user doubleclicks an .nzb-file and my program is not running, it should start and process it (easy, file registration). Now if my program is already running, I do NOT want to launch a second instance - I want the already-running instance to pick up the specified file.

Making my app single-instance can be done using the Visual Basic DLL with the .IsSingleInstance trick, but I don't want to go there.

The right way seems to be to use a mutex to ensure my app is single-instance, but now I'm stuck on how to pass the specified parameter (the .nzb file) to the already-running instance.

Help would be appreciated ! :-)

4
  • You're probably aware of this, but you may be reinventing the wheel with your application. sourceforge.net/projects/sabnzbd is but one example Commented May 27, 2009 at 21:16
  • 1
    Yup, and there are countless others ;-) It's a hobby-project just to flex my fingers with C#, and if I like the result the world may end up with just another freeware NZB-downloader ! :-) Commented May 27, 2009 at 21:21
  • 2
    Why don't you want to use the SingleInstanceController from Microsoft.VisualBasic.dll? It's an assembly within the framework like anyone else. Just because the name is VisualBasic it won't be used. If Microsoft had call it Microsoft.Foo.dll everyone would use it! Commented Feb 19, 2010 at 11:30
  • Oliver, it will add an additional dll reference. That's one reason, no matter what the name is ;-) Commented Apr 28, 2010 at 7:39

4 Answers 4

3

Try this: Your main program creates a named pipe or other interprocess communication facility and listens on it. You create a separate small program that, when run with an NZB file as a parameter, opens the pipe, feeds the file info into it, and exits. Your main program then processes the new file and downloads it.

Sign up to request clarification or add additional context in comments.

Comments

0

Why not have one program that adds the file to a queue, and then kicks off the downloading program if it is not already running. That downloading program watches the queue, which is just a file that you append download file names to.

Comments

0

Look at the InitialInstanceActivator at the Genghis project

Comments

0

Use an IPC (inter process communication) mechanism such as .net remoting

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.