Beispiel #1
0
        public static void Main(string[] args)
        {
            bool isRunOnMono = TraceLabSDK.RuntimeInfo.IsRunInMono;
            bool startInstance;

            if (!isRunOnMono)
            {
                //in windows TraceLab runs as single instance application
                //preventing TraceLab being open as multiple processes
                startInstance = (SingleInstance.InitializeAsFirstInstance(Unique));
            }
            else
            {
                //in mono don't use single instance startup
                //single instance must be developed in another way than on windows
                startInstance = true;
            }

            if (startInstance)
            {
                try
                {
                    try
                    {
                        Thread.CurrentThread.CurrentCulture = ThreadFactory.DefaultCulture;
                        var app = new TraceLabApplicationGUI();
                        app.Run(args);
                    }
                    catch (InvalidKeyException e)
                    {
                        if (!isRunOnMono)
                        {
                            System.Windows.Forms.MessageBox.Show(e.Message, @"Invalid key!",
                                                                 System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                        }
                        else
                        {
                            //attempt to display missing key warning in Gtk
                            TraceLabApplicationGUI.DisplayGtkErrorDialog(e.Message, "Warning");
                        }
                    }
                    catch (Exception e)
                    {
                        if (!isRunOnMono)
                        {
                            System.Windows.Forms.MessageBox.Show(e.Message, @"An Exception occurred.",
                                                                 System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }
                        else
                        {
                            //attempt to display error in Gtk (this is absolutely CRITICAL error, Gtk Main catches it's own unhandled exceptions)
                            TraceLabApplicationGUI.DisplayGtkErrorDialog(e.Message, "Error");
                        }
                    }
                }
                finally
                {
                    if (!isRunOnMono)
                    {
                        // Allow single instance code to perform cleanup operations
                        SingleInstance.Cleanup();
                    }
                }
            }
        }
        public static void Main(string[] args)
        {
            bool isRunOnMono = TraceLabSDK.RuntimeInfo.IsRunInMono;
            bool startInstance;
            if (!isRunOnMono)
            {
                //in windows TraceLab runs as single instance application
                //preventing TraceLab being open as multiple processes
                startInstance = (SingleInstance.InitializeAsFirstInstance(Unique));
            }
            else
            {
                //in mono don't use single instance startup
                //single instance must be developed in another way than on windows
                startInstance = true;
            }

            if(startInstance) 
            {
                try
                {
                    try
                    {
                        Thread.CurrentThread.CurrentCulture = ThreadFactory.DefaultCulture;
                        var app = new TraceLabApplicationGUI();
                        app.Run(args);
                    }
                    catch (InvalidKeyException e)
                    {
                        if (!isRunOnMono)
                        {
                            System.Windows.Forms.MessageBox.Show(e.Message, @"Invalid key!",
                                                          System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                        }
                        else
                        {
                            //attempt to display missing key warning in Gtk 
                            TraceLabApplicationGUI.DisplayGtkErrorDialog(e.Message, "Warning");
                        }
                    }
                    catch (Exception e)
                    {
                        if (!isRunOnMono)
                        {
                            System.Windows.Forms.MessageBox.Show(e.Message, @"An Exception occurred.",
                                                             System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }
                        else
                        {
                            //attempt to display error in Gtk (this is absolutely CRITICAL error, Gtk Main catches it's own unhandled exceptions) 
                            TraceLabApplicationGUI.DisplayGtkErrorDialog(e.Message, "Error");
                        }
                    }
                }
                finally
                {
                    if (!isRunOnMono)
                    {
                        // Allow single instance code to perform cleanup operations
                        SingleInstance.Cleanup();
                    }
                }
            }
        }