detect 2nd instance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug Bell

    #1

    detect 2nd instance

    Hi
    can anyone point me in the right direction of detecting if an application is
    running so that if a 2nd instance is started it can check and self
    terminate?

    Thanks

    Doug


  • vijrag

    #2
    RE: detect 2nd instance

    Hi Doug,

    If Process.GetProc essesByName
    (Process.GetCur rentProcess.Pro cessName).Lengt h > 1 Then
    MessageBox.Show ("Another Instance of this process is already running")
    Application.Exi t()
    End If

    Vijrag.
    "Doug Bell" wrote:
    [color=blue]
    > Hi
    > can anyone point me in the right direction of detecting if an application is
    > running so that if a 2nd instance is started it can check and self
    > terminate?
    >
    > Thanks
    >
    > Doug
    >
    >
    >[/color]

    Comment

    • Joerg Jooss

      #3
      Re: detect 2nd instance

      Doug Bell wrote:[color=blue]
      > Hi
      > can anyone point me in the right direction of detecting if an
      > application is running so that if a 2nd instance is started it can
      > check and self terminate?[/color]

      There's a nice solution for this in Chris Sells' book Windows Form
      Porgramming in {C#|VN.NET}. You can get the code from his web site at
      http://www.sellsbrothers.com/writing/wfbook/.

      Cheers,

      --
      Joerg Jooss
      joerg.jooss@gmx .net


      Comment

      • Doug Bell

        #4
        Thanks

        Doug


        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: detect 2nd instance

          Doug Bell <dug@bigpond> wrote:[color=blue]
          > can anyone point me in the right direction of detecting if an application is
          > running so that if a 2nd instance is started it can check and self
          > terminate?[/color]

          See http://www.pobox.com/~skeet/csharp/f...ation.instance

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          Working...