Detecting prior instances of an application

From: Chris (dunawayc_at_gmail.com)
Date: 01/06/05


Date: 6 Jan 2005 12:13:43 -0800

I need to be able to detect a prior instance of my application (console
app) if it is run again. The app is normally run on a set schedule and
most of the time, the first instance will be finished before it is run
again, but occasionally, the first app will not complete in a timely
enough fashion and may still be processing when the schedule kicks it
off again.

I know I can use a Mutex for this purpose, but I additionally need for
the second instance to somehow signal the first so it knows it has
additional processing to do.

Something like this:

First instance starts and begins processing.
Second instance is kicked off before first instance finishes.
Second instance detects first instance and signals first instance
(How??)
Second instance closes.
First instance finishes processing and sees that the second instance
has signalled it.
First instance begins processing again.

What mechanism would be the easiest for the second instance to signal
the first? Would a semaphore be appropriate in this instance? Does
the .Net framework support semaphores? I will check that out, but does
anyone have any other suggestions?

Thanks,



Relevant Pages

  • Re: cant bring "single instance" tray app to foreground
    ... frontmost/active window. ... anything since (because this is a trap app) the main window ... the second instance of your app needs to ... call AllowSetForegroundWindowso that the first instance ...
    (microsoft.public.vc.mfc)
  • Re: Multiple Instances of an App
    ... instances the first instance wins and therefore the running instance (the ... mutex owner relinquishes the mutex. ... So, send the message from the second instance to the first, as described ... then there is an app. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Search and Destroy.
    ... I'm convinced it's a Windows thing, primaril because FileLocatorPro ... I ran a second instance of Search (for the ... |>went back to the First Instance, deleted one file and the Second ...
    (microsoft.public.windowsxp.general)
  • Re: Search and Destroy.
    ... A temp file, one in use or non existent file is the most common reason ... |>went back to the First Instance, deleted one file and the Second Instance ... "Group Deletes" still report the same error. ...
    (microsoft.public.windowsxp.general)
  • Detecting prior instances of an application
    ... app) if it is run again. ... First instance starts and begins processing. ... Second instance is kicked off before first instance finishes. ... Second instance detects first instance and signals first instance ...
    (microsoft.public.dotnet.languages.vb)