views:

234

answers:

3

Hi All,

I am working on the application (C# 2.0). I have implemented single instance in it. Everything is fine. If i run the application again, it shows messagebox saying "instance is already running".

Actually i don't want to show the message through messagebox.

I want to show this message using Balloon tip of already running instance (it has notify icon in system tray).

How can i achieve this?

Thanks in advance.

+4  A: 

You need a form of interprocess communication, to signal to the other instance that it should display the messagebox.

In this instance, you could go one better than telling the existing instance to display the message, and instead tell it to restore it's main window (i.e. "unminimise").

Neil Barnwell
I recommend just opening a socket and sending a wake up signal to the application. Everything you'll need is build into .NET (look into the TcpListener/TcpClient classes).
Ron Warholic
A: 

You could use a WCF service inside you app.

Your second app connects to it via NetPipe, invode a method and closes.

Your first app receive the call and pops-up the baloon notification

vIceBerg
A: 

The easiest way to implement a single instance and to inform the first one if a second is started is already implement in .Net. Just take a look into the following links:

Hanselman: Single Instance WinForms

OpenWinForms (select True Single Instance application)

Oliver