Stop Multiple Instances

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!
 
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!

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
}
}
 
C

Chris Tacke, MVP

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
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top