Results 1 to 3 of 3

Thread: [RESOLVED] Check if this is the last instance of an appliction on closing.

  1. #1

    Thread Starter
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Resolved [RESOLVED] Check if this is the last instance of an appliction on closing.

    To close a independend application (a Chat program)
    I need to know if my application is the last instance of this application running on a system.
    I can of course iterate through all proccesses, but I was hoping there would be a simpler way to achive this task.

    Using Counters to keep track of the number of instances is not a way 'I want to go, for it would flaw on a crash of any instance.

    A mutex would be a problem if the first instance is closed first...

    Does anyone know a simple straightforward solution to this problem?

    Thanks in advance,
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Check if this is the last instance of an appliction on closing.

    vb.net Code:
    1. If Process.GetProcessesByName("process name here").Length = 1 Then
    2.     'This is the last instance.
    3. End If
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: Check if this is the last instance of an appliction on closing.

    Thx,

    I will look into this concept tommorrow

    See Ya!

    Dnereb
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width