public void Initialize(string username, ApplicationForm appForm) { this.appForm = appForm; this.lblProcess = appForm.lblMessage; this.progressBar = appForm.progressBar; this.btnImport = appForm.btnStart; try { UserInfo info = UserController.GetUser(username); SecurityContext.SetThreadPrincipal(info); } catch (Exception ex) { ShowError("Unable to authenticate user", ex); Cancel(); } }
static void Main() { Log.WriteApplicationStart(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ApplicationExit += new EventHandler(OnApplicationExit); appForm = new ApplicationForm(); Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnApplicationException); ConnectForm connectForm = new ConnectForm(); if (connectForm.ShowDialog() == DialogResult.OK) { appForm.InitializeForm(connectForm.Username, connectForm.Password); Application.Run(appForm); } }