internal async Task<Connection> AskForConnectionAsync() { using (var closedEvent = new System.Threading.ManualResetEvent(false)) { var dialog = new ConnectionDialog(); dialog.Closed += (sender, e) => { closedEvent.Set(); }; dialog.Show(); await Task.Run(new Action(() => closedEvent.WaitOne())); if (dialog.Ok ?? false) return dialog.Connection; else return null; } }
internal async Task <Connection> AskForConnectionAsync() { using (var closedEvent = new System.Threading.ManualResetEvent(false)) { var dialog = new ConnectionDialog(); dialog.Closed += (sender, e) => { closedEvent.Set(); }; dialog.Show(); await Task.Run(new Action(() => closedEvent.WaitOne())); if (dialog.Ok ?? false) { return(dialog.Connection); } else { return(null); } } }