public async Task<bool> ConnectAsync(string name, string host, string password) { bool result = false; ServerConnection connection = null; if (!string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(host) && !string.IsNullOrWhiteSpace(password)) { connection = new ServerConnection(host, name); Task<bool> connectionTask = connection.ConnectAsync(password); SetStatusLabel(string.Format("Attempting to connect to: {0}@{1}", name, host)); toolStripProgressBar1.ProgressBar.Style = ProgressBarStyle.Marquee; result = await connectionTask; } if (result) { _connection = connection; _connection.UploadProgress += (sender, e) => UpdateProgress(e); _connection.UploadStart += (sender, e) => SetStatusLabel("Uploading file " + e.FilePath + "..."); SetStatusLabel("Loading Databases from server..."); await RefreshDatabases(); SetStatusLabel(); SetTitle(string.Format("{0}@{1}", _connection.UserName, _connection.Host)); toolStripProgressBar1.ProgressBar.Style = ProgressBarStyle.Continuous; submitToolStripMenuItem.Enabled = true; } else { submitToolStripMenuItem.Enabled = false; toolStripProgressBar1.ProgressBar.Style = ProgressBarStyle.Continuous; SetStatusLabel(string.Format("Unable to Connected To: {0}@{1}", name, host)); } return result; }
public async Task <bool> ConnectAsync(string name, string host, string password) { bool result = false; ServerConnection connection = null; if (!string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(host) && !string.IsNullOrWhiteSpace(password)) { connection = new ServerConnection(host, name); Task <bool> connectionTask = connection.ConnectAsync(password); SetStatusLabel(string.Format("Attempting to connect to: {0}@{1}", name, host)); toolStripProgressBar1.ProgressBar.Style = ProgressBarStyle.Marquee; result = await connectionTask; } if (result) { _connection = connection; _connection.UploadProgress += (sender, e) => UpdateProgress(e); _connection.UploadStart += (sender, e) => SetStatusLabel("Uploading file " + e.FilePath + "..."); SetStatusLabel("Loading Databases from server..."); await RefreshDatabases(); SetStatusLabel(); SetTitle(string.Format("{0}@{1}", _connection.UserName, _connection.Host)); toolStripProgressBar1.ProgressBar.Style = ProgressBarStyle.Continuous; submitToolStripMenuItem.Enabled = true; } else { submitToolStripMenuItem.Enabled = false; toolStripProgressBar1.ProgressBar.Style = ProgressBarStyle.Continuous; SetStatusLabel(string.Format("Unable to Connected To: {0}@{1}", name, host)); } return(result); }