G
Guest
It seems like in a compact frameworks application if a user is very anxious
and clicks twice on the icon to start the application within a couple of
seconds, it starts two instances of the program, once the application is
running, it only sets the program to the top level window.
I found some code that makes sense that would eliminate the problem
[DllImport("coredll.dll", EntryPoint = "CreateMutexW")]
private static extern int CreateMutex(IntPtr lpMutexAttributes, bool
InitialOwner, string MutexName);
string mutexName = "XXXXX_MOBILE_APP";
CreateMutex(IntPtr.Zero, true, mutexName)
if(GetLastError() == ERROR_ALREADY_EXISTS)
ShutDown();
However everytime when I'm calling the the GetLastError() message I always
get a ERROR_INVALID_HANDLE return code. However I do get a non-NULL mutex
handle.
Any help would be appreciated!
and clicks twice on the icon to start the application within a couple of
seconds, it starts two instances of the program, once the application is
running, it only sets the program to the top level window.
I found some code that makes sense that would eliminate the problem
[DllImport("coredll.dll", EntryPoint = "CreateMutexW")]
private static extern int CreateMutex(IntPtr lpMutexAttributes, bool
InitialOwner, string MutexName);
string mutexName = "XXXXX_MOBILE_APP";
CreateMutex(IntPtr.Zero, true, mutexName)
if(GetLastError() == ERROR_ALREADY_EXISTS)
ShutDown();
However everytime when I'm calling the the GetLastError() message I always
get a ERROR_INVALID_HANDLE return code. However I do get a non-NULL mutex
handle.
Any help would be appreciated!