public async void ConnectToServer(List <VMDirServerDTO> server) { ProgressWindowController pwc = new ProgressWindowController(); IntPtr session = new IntPtr(0); ConnectToLdapWindowController awc = new ConnectToLdapWindowController(server); NSApplication.SharedApplication.BeginSheet(awc.Window, this.Window, () => { }); nint result = NSApplication.SharedApplication.RunModalForWindow(awc.Window); try { if (result == VMIdentityConstants.DIALOGOK) { NSApplication.SharedApplication.BeginSheet(pwc.Window, this.Window as NSWindow, () => { }); session = NSApplication.SharedApplication.BeginModalSession(pwc.Window); serverNode = awc.ServerDTO; await serverNode.DoLogin(); InitialiseViews(); } } catch (Exception e) { serverNode.IsLoggedIn = false; UIErrorHelper.ShowAlert(VMDirConstants.ERR_LOGIN_FAILED + " : " + e.Message, "Login not successful!"); } finally { if (pwc.ProgressBar != null) { pwc.ProgressBar.StopAnimation(pwc.Window); pwc.Window.Close(); NSApplication.SharedApplication.EndModalSession(session); } Window.EndSheet(awc.Window); awc.Dispose(); } }