private Thread StartUIThread() { // Start a new UI thread to run the browser dialog on so that we can block this one and present // a synchronous interface to callers. Thread uiSubThread = new Thread( () => { try { formsSyncContext = new WindowsFormsSynchronizationContext(); dialog = new SilentWindowsFormsAuthenticationDialog(this.OwnerWindow) { NavigationWaitMiliSecs = NavigationWaitMiliSecs, RequestContext = RequestContext }; dialog.Done += UIDoneHandler; threadInitializedEvent.Set(); dialog.AuthenticateAAD(this.RequestUri, this.CallbackUri); // Start and turn control over to the message loop. Application.Run(); result = dialog.Result; } catch (Exception e) { RequestContext.Logger.Error(e); // Catch all exceptions to transfer them to the original calling thread. uiException = e; } }); uiSubThread.SetApartmentState(ApartmentState.STA); uiSubThread.IsBackground = true; uiSubThread.Start(); return(uiSubThread); }
private Thread StartUIThread(string headers) { // Start a new UI thread to run the browser dialog on so that we can block this one and present // a synchronous interface to callers. Thread uiSubThread = new Thread( () => { try { this.formsSyncContext = new WindowsFormsSynchronizationContext(); this.dialog = new SilentWindowsFormsAuthenticationDialog(this.OwnerWindow) { NavigationWaitMiliSecs = NavigationWaitMiliSecs }; this.dialog.Done += this.UIDoneHandler; this.threadInitializedEvent.Set(); this.dialog.AuthenticateAAD(this.RequestUri, this.CallbackUri, headers); // Start and turn control over to the message loop. Application.Run(); this.result = this.dialog.Result; } catch (Exception e) { PlatformPlugin.Logger.Error(null, e); // Catch all exceptions to transfer them to the original calling thread. this.uiException = e; } }); uiSubThread.SetApartmentState(ApartmentState.STA); uiSubThread.IsBackground = true; uiSubThread.Start(); return uiSubThread; }