Click here to Skip to main content
15,888,610 members
Home / Discussions / Mobile
   

Mobile

 
QuestionRe: Excel file Pin
danhpt8-Nov-08 17:28
danhpt8-Nov-08 17:28 
AnswerRe: Excel file Pin
ujjawal kumar12-May-09 2:45
ujjawal kumar12-May-09 2:45 
QuestionConfiguration Quandary Pin
pdohara7-Nov-08 5:55
pdohara7-Nov-08 5:55 
QuestionHow to load a client driver programatically... Pin
abupriabi@yahoo.com6-Nov-08 10:45
abupriabi@yahoo.com6-Nov-08 10:45 
Questionstop multiple instance of same program Pin
Cory Kimble5-Nov-08 4:42
Cory Kimble5-Nov-08 4:42 
AnswerRe: stop multiple instance of same program Pin
Joel Ivory Johnson5-Nov-08 17:59
professionalJoel Ivory Johnson5-Nov-08 17:59 
AnswerRe: stop multiple instance of same program Pin
Giannakakis Kostas6-Nov-08 3:08
professionalGiannakakis Kostas6-Nov-08 3:08 
AnswerRe: stop multiple instance of same program Pin
PavanPareta7-Nov-08 2:16
PavanPareta7-Nov-08 2:16 
Hi Cory Kimble,

By default CF .NET apps are supposed to be single instance. However sometimes, if you try to launch an app quickly you might get multiple instances.


you can use the following code to enforce single instance (http://www.nesser.org/blog/archives/56)




Code Snippet

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace SomeNameSpace
{
 static class SingleInstance
 {
  [MTAThread]
  static void Main()
  {
   // Check if we have a duplicate instance of the program running
   if ( IsInstanceRunning() )
   {
    // Perhaps log the fact a duplicate program was shut down
    return;
   }

   /*
    * Continue with your normal program here
    */

   try
   {
    Application.Run( YourFormClass );
   }
   catch ( Exception e )
   {
    // Log an exception that caused the application to close here
    MessageBox.Show( "See log file for details.\r\nClosing this application.", "Fatal Application Error" );
   }
  }

#region OpenNETCF native interface to mutex generation (version 1.4 of the SDF)

  public const Int32 NATIVE_ERROR_ALREADY_EXISTS = 183;

#region P/Invoke Commands for Mutexes
  [DllImport( "coredll.dll", EntryPoint="CreateMutex", SetLastError=true )]
  public static extern IntPtr CreateMutex(
   IntPtr lpMutexAttributes,
   bool InitialOwner,
   string MutexName );

  [DllImport( "coredll.dll", EntryPoint="ReleaseMutex", SetLastError=true )]
  public static extern bool ReleaseMutex( IntPtr hMutex );
#endregion

  public static bool IsInstanceRunning()
  {
   IntPtr hMutex = CreateMutex( IntPtr.Zero, true, "ApplicationName" );
   if ( hMutex == IntPtr.Zero )
    throw new ApplicationException( "Failure creating mutex: "
     + Marshal.GetLastWin32Error().ToString( "X" ) );

   if ( Marshal.GetLastWin32Error() == NATIVE_ERROR_ALREADY_EXISTS )
    return true;
   else
    return false;
  }
#endregion
 }
}


Pavan Pareta

AnswerRe: stop multiple instance of same program Pin
Jakob Olsen13-Jul-09 9:41
Jakob Olsen13-Jul-09 9:41 
QuestionHow to transfer file via bluetooth from desktop PC to Windows Mobile Device Pin
yudhisthira31-Oct-08 19:14
yudhisthira31-Oct-08 19:14 
AnswerRe: How to transfer file via bluetooth from desktop PC to Windows Mobile Device Pin
Joel Ivory Johnson4-Nov-08 19:07
professionalJoel Ivory Johnson4-Nov-08 19:07 
Questioncan any one help me ? Pin
yemen_programer30-Oct-08 0:30
yemen_programer30-Oct-08 0:30 
AnswerUsing bluetooth for downloading Pin
Joel Ivory Johnson4-Nov-08 19:02
professionalJoel Ivory Johnson4-Nov-08 19:02 
GeneralRe: Using bluetooth for downloading Pin
yemen_programer5-Nov-08 21:32
yemen_programer5-Nov-08 21:32 
GeneralRe: Using bluetooth for downloading Pin
Joel Ivory Johnson6-Nov-08 5:18
professionalJoel Ivory Johnson6-Nov-08 5:18 
QuestionPlz Help Pin
wasimsharp30-Oct-08 0:18
wasimsharp30-Oct-08 0:18 
AnswerCP IGNORE: cross poster Pin
leckey30-Oct-08 9:33
leckey30-Oct-08 9:33 
QuestionCERDISP2.exe and CeRHost.exe Pin
Tushar Mahajan30-Oct-08 0:02
Tushar Mahajan30-Oct-08 0:02 
QuestionIdentifying and killing a process using C# in .netcf 2.0 Pin
rwal90129-Oct-08 10:00
rwal90129-Oct-08 10:00 
AnswerRe: Identifying and killing a process using C# in .netcf 2.0 Pin
Giannakakis Kostas3-Nov-08 2:14
professionalGiannakakis Kostas3-Nov-08 2:14 
QuestionData Transfer via GSM connection Pin
tronix0129-Oct-08 6:37
tronix0129-Oct-08 6:37 
AnswerRe: Data Transfer via GSM connection Pin
Joel Ivory Johnson4-Nov-08 18:46
professionalJoel Ivory Johnson4-Nov-08 18:46 
QuestionNot able to create bluetooth socket on wince device - HP iPAQ Pin
yudhisthira28-Oct-08 18:54
yudhisthira28-Oct-08 18:54 
AnswerRe: Not able to create bluetooth socket on wince device - HP iPAQ Pin
Hurricane300029-Oct-08 4:45
Hurricane300029-Oct-08 4:45 
QuestionTurning on a program Pin
danialhill26-Oct-08 20:07
danialhill26-Oct-08 20:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.