static void Main(string[] args) { Thread.CurrentThread.Name = "NeoMainThread"; InitializeBeHwApiLog(); if (!CheckIfApplicationCanRun()) return; UserStartupMessage.SendUserStartupMessageToBeijerShell("Loading Files"); if (!StopWatchCF.Silent) StopWatchCF.Send("Starting Project"); StopWatchCF.SetTimeStamp("***** Project Startup Time *****"); while (ProcessExplorer.WaitForAttachDebugger) { Thread.Sleep(1000); } IsCompiledForCE = true; Instance = new Globals(); try { m_Arguments = args; m_ToolManager.OnToolAdded += OnToolAdded; m_ToolManager.LoadTools(); SetRenderingMode(); INativeAPI nativeAPI = Globals.GetService<IPlatformFactoryService>().Create<INativeAPI>(); int mutexHandle = CreateMutex(nativeAPI); bool mutexAquired = mutexHandle != 0 && (Marshal.GetLastWin32Error() != (int)CREATEMUTEX.ERROR_ALREADY_EXISTS) && (Marshal.GetLastWin32Error() != (int)CREATEMUTEX.ERROR_ACCESS_DENIED) ; if (mutexAquired) { ((Globals)Instance).SetBeShellMenuPassword(); ((Globals)Instance).SetScreenOrientation(); ((Globals)Instance).SetSerialPortMode(); ((Globals)Instance).SetKeyBeep(); ((Globals)Instance).ConfigureFtpServer(); ((Globals)Instance).StartVncServerCe(); nativeAPI.CeSetThreadQuantum(new IntPtr(65), 25); InterpreterArguments(args); ExecutablePath = typeof(Globals).Module.FullyQualifiedName; RegisterDrivers(); NeoApplication.Initialize(); m_ToolManager.Start(); Instanciate(new string[] {"TextLibrary","Security","Tags","MultipleLanguages","AlarmServer","Database","Expressions","LicenseRootComponent","ProjectConfiguration","SntpClientRootComponent","UnitsAndConversion","DrawScreen","Recording","Comm","SolenoidValveControl","CalAndUpdate","MainTimer","Definition","Buzzer","DefaultSettings","InternalSettings","PersistentVariables","DecimalSettings","FilterSettingMid","StabSettingMid","StabSettingLow","FilterSettingLow","ProjectImages"}); PreloadScreens = new string[] {}.Select(item => Type.GetType(string.Concat(StringConstants.NeoApplicationFrameworkGenerated, ".", item, ",", Assembly.GetExecutingAssembly().FullName), true)).ToArray(); InitAndRun(); NeoApplication.SetMainScreen(StartScreen.AdaptedObject); NeoApplication.Run(StartScreen.AdaptedObject.GetType()); CloseRunningOnScreenKeyboard(); CloseRunningVncserverCe(); } } catch(ControledRequestForShutdownException ex) { MessageBox.Show(ex.Message); } catch(Exception ex) { GenerateCrashReport(ex); ManageUnhandledException(ex, true); m_ShowUnhandledException = false; throw; //Preserves stacktrace and triggers Dr Watson to create dump file. } finally { try { m_ToolManager.StopStoppable(); Stop(); } catch (Exception e) { m_Log.Info("Unable to successfully stop.", e); } } }