Stop Multiple Instances

  • Thread starter Thread starter Jerod Houghtelling
  • Start date Start date
J

Jerod Houghtelling

Does anyone know how to stop multiple instances of an application from
running? I know the compact framework is not suppose to allow this
behavior in the first place, but it is happing on the Dolphin/
Honeywell devices that our company uses.

I have an application approximately 1 MB in size. My test application
consists of trying to fire off the process multiple times, and it does
successfully. I have even verified in memory there are two separate
processes running.

static void Main()
{
Process.Start( @"\Program Files\CUI.Net\CUMobile\CUMobile.exe", "" );
Process.Start( @"\Program Files\CUI.Net\CUMobile\CUMobile.exe", "" );
}

A Mutex would have been nice, but the compact framework version isn't
able to cross processes. Any ideas or help is very appreciated.

Thanks!
 
Does anyone know how to stop multiple instances of an application from
running? I know the compact framework is not suppose to allow this
behavior in the first place, but it is happing on the Dolphin/
Honeywell devices that our company uses.

I have an application approximately 1 MB in size. My test application
consists of trying to fire off the process multiple times, and it does
successfully. I have even verified in memory there are two separate
processes running.

static void Main()
{
        Process.Start( @"\Program Files\CUI.Net\CUMobile\CUMobile..exe", "" );
        Process.Start( @"\Program Files\CUI.Net\CUMobile\CUMobile..exe", "" );

}

A Mutex would have been nice, but the compact framework version isn't
able to cross processes. Any ideas or help is very appreciated.

Thanks!

I think I have it working now. Luckily the OpenNetCF has a NamedMutex
class that I was able to use.

public static void Main( string[] args )
{
bool firstInstance;
NamedMutex mutex = new NamedMutex( false, MUTEX_ID, out
firstInstance );

if( firstInstance )
{
// Load the application
}
}
 
Yep, that's the way to do it.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

Does anyone know how to stop multiple instances of an application from
running? I know the compact framework is not suppose to allow this
behavior in the first place, but it is happing on the Dolphin/
Honeywell devices that our company uses.

I have an application approximately 1 MB in size. My test application
consists of trying to fire off the process multiple times, and it does
successfully. I have even verified in memory there are two separate
processes running.

static void Main()
{
Process.Start( @"\Program Files\CUI.Net\CUMobile\CUMobile.exe", "" );
Process.Start( @"\Program Files\CUI.Net\CUMobile\CUMobile.exe", "" );

}

A Mutex would have been nice, but the compact framework version isn't
able to cross processes. Any ideas or help is very appreciated.

Thanks!

I think I have it working now. Luckily the OpenNetCF has a NamedMutex
class that I was able to use.

public static void Main( string[] args )
{
bool firstInstance;
NamedMutex mutex = new NamedMutex( false, MUTEX_ID, out
firstInstance );

if( firstInstance )
{
// Load the application
}
}
 
Back
Top