void timer_Tick(object sender, EventArgs e) { timer.Stop(); timer.Tick -= timer_Tick; AutoResetEvent waitHandle = new AutoResetEvent(false); ServiceManager.Add <System.Threading.EventWaitHandle>(waitHandle); AuthenticateService authenticateService = new ProWriteAuthenticateService(); var hasAuth = authenticateService.Authenticate(); if (hasAuth) { HasAuthenticated = true; } else { using (var loginForm = StartHelper.CreateLoginForm()) { loginForm.AuthenticateService = authenticateService; loginForm.ShowDialog(this); HasAuthenticated = authenticateService.HasAuthenticated; } } waitHandle.WaitOne(); ServiceManager.Remove <System.Threading.EventWaitHandle>(); waitHandle.Close(); Hide(); Close(); }
public Thread(ParameterizedThreadStart start) { ArgumentNullException.ThrowIfNull(start); _startHelper = new StartHelper(start); Initialize(); }
public Thread(ThreadStart start) { if (start == null) { throw new ArgumentNullException(nameof(start)); } _startHelper = new StartHelper(start); Initialize(); }
public static ArgInfo Parse(string file) { var factory = StartHelper.CreateImportExportFactory(); var ret = new ArgInfo(); ret.Importer = factory.Create(file); ret.Extension = factory.Extension; ret.ModuleName = factory.ModuleName; return(ret); }
public Thread(ParameterizedThreadStart start, int maxStackSize) { ArgumentNullException.ThrowIfNull(start); if (maxStackSize < 0) { throw new ArgumentOutOfRangeException(nameof(maxStackSize), SR.ArgumentOutOfRange_NeedNonNegNum); } _startHelper = new StartHelper(start) { _maxStackSize = maxStackSize }; Initialize(); }
public Thread(ThreadStart start, int maxStackSize) { if (start == null) { throw new ArgumentNullException(nameof(start)); } if (maxStackSize < 0) { throw new ArgumentOutOfRangeException(nameof(maxStackSize), SR.ArgumentOutOfRange_NeedNonNegNum); } _startHelper = new StartHelper(start) { _maxStackSize = maxStackSize }; Initialize(); }
//public static void Main(string[] args) //{ // CreateHostBuilder(args).Build().Run(); //} //public static IHostBuilder CreateHostBuilder(string[] args) => // Host.CreateDefaultBuilder(args) // .ConfigureWebHostDefaults(webBuilder => // { // webBuilder.UseDefaultServiceProvider(options => { options.ValidateScopes = false; }); // webBuilder.UseStartup<Startup>(); // }); public static void Main(string[] args) { StartHelper.Start <Startup>("Company.Api", args); }
public static void Main(string[] args) { FileHelper.CreateDirectory(UploadImg); StartHelper.Start <Startup>("OA Api", args); }
public void DoRun(params string[] args) { ArgInfo argInfo = null; //MessageBox.Show("Hello!"); if (args != null && args.Length == 1) { argInfo = ArgInfo.Parse(args[0]); } var currentPro = Process.GetCurrentProcess(); bool created; using (Mutex mtx = new Mutex(true, API.mainWindowName, out created)) { if (!created) { if (argInfo != null) { HandlerPreviewProcessInfo(args, currentPro); } return; } var loginTask = Task.Create(p => ShowSplash()); CodeTimer.Time("Start Main Form", () => { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); XmlConfigurator.Configure(); Log.InnerLog = new ProWrite.Core.Logger("-Sys-"); string moduleName = null; object[] argArrary = null; mainForm = StartHelper.CreateMainForm(); (mainForm as IMainForm).Initialize(); var profile = ServiceManager.Get <ProjectProfile>(); Task registerModuleTask = null; registerModuleTask = Task.Create(p => { if (moduleName == null) { moduleName = profile.DefaultModule; } var moduleInfo = profile.Modules.First(m => m.ModuleName == moduleName); ModuleManager.Register(moduleInfo.Module); var modules = profile.Modules.Where(m => m.ModuleName != moduleName); foreach (var m in modules) { ModuleManager.Register(m.Module); } }); var timer = ServiceManager.Get <System.Windows.Forms.Timer>(); mainForm.Shown += (s, e) => { ModuleManager.DisplayModule(ModuleNames.Editor); //moduleName); ModuleManager.DisplayModule(moduleName); timer.Tick += delegate { timer.Stop(); if (argInfo != null) { moduleName = argInfo.ModuleName; argArrary = new object[] { argInfo.Importer.OnImportOpen(args[0]), true }; ModuleManager.DisplayModule(moduleName, argArrary); } if (!registerModuleTask.IsCompleted) { registerModuleTask.Wait(); registerModuleTask.Dispose(); } if (!loginTask.IsCompleted) { loginTask.Wait(); loginTask.Dispose(); } //TODO: DirtyWordList.Load(); }; timer.Start(); }; ServiceManager.Add <bool>(false); filter = new UserPreferenceChangingFilter(); Application.AddMessageFilter(filter); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); Application.ApplicationExit += new EventHandler(Application_ApplicationExit); }); while (!HasAuthenticated.HasValue) { loginTask.Wait(50); } var ewh = ServiceManager.Get <System.Threading.EventWaitHandle>(); ewh.Set(); if (!HasAuthenticated.Value) { Application.Exit(); return; } Application.Run(mainForm); } }