static void Main() { #if DEBUG //#warning COMMENTED_CODE_HERE!!! // SetTestServiceUrls(); // IsAdmin = true; IsDebug = true; #else IsAdmin = false; IsDebug = false; #endif ThreadPool.SetMaxThreads(50, 100); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-us"); Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException); DelegateBase.Error += new ThreadExceptionEventHandler(OnThreadException); VoucherPrinter.Error += new ThreadExceptionEventHandler(OnThreadException); PrinterQueue.Error += new ThreadExceptionEventHandler(OnThreadException); DelegateHelper.Error += new ThreadExceptionEventHandler(OnThreadException); Global.Error += new ThreadExceptionEventHandler(OnThreadException); StateSaver.Default.Path = Path.ChangeExtension(Application.ExecutablePath, "dat"); StateSaver.Default.Load(); PluginLoader.Error += new ThreadExceptionEventHandler(OnThreadException); string path = Path.GetDirectoryName(Application.ExecutablePath); loader.Process(path, PluginLoader.Operation.Start); StateSaver.Default.Set(Strings.ClearScanDirectory, ConfigurationManager.AppSettings["ClearScanDirectory"].Cast <bool>()); BarcodeConfig.Init(); Speeker.Enabled = ConfigurationManager.AppSettings["SPEAK"].Cast <bool>(); StateSaver.Default.Set(Strings.VERSION, Assembly.GetEntryAssembly().GetName()); #if !DEBUG if (ConfigurationManager.AppSettings["USE_SCAN_SERVER"].Cast <bool>()) { if (!File.Exists(ConfigurationManager.AppSettings["ScanServerPath"])) { MessageBox.Show("Cannot find scan server.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { ConfigurationManager.AppSettings["ScanServerPath"].StartProcessSafe(); } } #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FormLogin frmLogin = new FormLogin(); if (frmLogin.ShowDialog() == DialogResult.OK) { Application.Run(new MainForm()); } StateSaver.Default.Save(); DelegateHelper.Close(); new Action(() => { var downloadDir = MainForm.GetAppSubFolder(Strings.DOWNLOAD); downloadDir.Delete(true); }).RunSafe(); Global.Instance.DisposeSf(); loader.Process(path, PluginLoader.Operation.Stop); }