static void Main()
        {
            // Use the SingleInstanceManager to ensure that only one instance
            // of PSM can be launched
            using (SingleInstanceManager sim = new SingleInstanceManager())
            {
                // If there is already one running, request the process
                // to come to the foreground
                if (sim.EventAlreadyExists())
                {
                    sim.SignalEvent();
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    // Instantiate the application context
                    PsmApplicationContext appContext = new PsmApplicationContext();

                    // Only start the application if the intialisation succeeds
                    if (appContext.initialise())
                    {
                        // Set the callback for displaying the main window
                        sim.setObject(appContext.getSmf(), appContext.getSmf().showApplication);
                        // Start the main event loop
                        Application.Run(appContext);

                        // Make sure all threads exit after the end of the Run method
                        Environment.Exit(0);
                    }
                }
            }
        }
        static void Main()
        {
            // Use the SingleInstanceManager to ensure that only one instance
            // of PSM can be launched
            using (SingleInstanceManager sim = new SingleInstanceManager())
            {
                // If there is already one running, request the process
                // to come to the foreground
                if (sim.EventAlreadyExists())
                {
                    sim.SignalEvent();
                }
                else
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    // Instantiate the application context
                    PsmApplicationContext appContext = new PsmApplicationContext();

                    // Only start the application if the intialisation succeeds
                    if (appContext.initialise())
                    {
                        // Set the callback for displaying the main window
                        sim.setObject(appContext.getSmf(), appContext.getSmf().showApplication);
                        // Start the main event loop
                        Application.Run(appContext);

                        // Make sure all threads exit after the end of the Run method
                        Environment.Exit(0);
                    }
                }
            }
        }