Results 1 to 3 of 3

Thread: Single Instance of Application problem

  1. #1

    Thread Starter
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681

    Single Instance of Application problem

    I have the following code to allow a single instance of my application.
    VB Code:
    1. Dim process() As process
    2.  
    3.         process = System.Diagnostics.Process.GetProcessesByName("AppNameHere") 'System.Diagnostics.Process.GetCurrentProcess.ProcessName)
    4.         If process.Length = 1 Then 'Not already running
    5.             Return False
    6.         Else 'Already running
    7.             Return True
    8.         End If

    My problem is that when the icon for the application is double clicked to launch, and then double clicked again to launch before anything has loaded - both attempts are caught as a multiple instance and nothing loads.

    Is there a way to make this load the first instance and not allow any others even during the loading process?

    I have also tried using a mutex to the same results.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Using Mutex is much faster here is an example:
    http://www.vbcity.com/forums/topic.asp?tid=25500

  3. #3

    Thread Starter
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Thanks! That was exactly what I was looking for! Works great!

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