private async void Button1_Click(object sender, EventArgs e) { string username = textBox1.Text; string password = textBox2.Text; label4.Visible = true; label4.Text = "Logging in..."; progressBar1.Visible = true; IProgress <int> progress = new Progress <int>(value => { progressBar1.Value = value; }); User u = null; bool success = false; await Task.Run(() => { progress.Report(33); int userId = remoteProxy.GetUser(username, password).Result; progress.Report(66); if (userId > -1) { progress.Report(99); u = remoteProxy.GetUserData(userId).Result; success = true; } }); if (success) { Hide(); Form2 LOGIN = new Form2(remoteProxy, u); LOGIN.ShowDialog(); Close(); } else { //Show error message label3.Visible = true; progress.Report(0); } }
private void button1_Click(object sender, EventArgs e) { string username = textBox1.Text; string password = textBox2.Text; int userId = remoteProxy.GetUser(username, password); if (userId > -1) { User u = remoteProxy.GetUserData(userId); Hide(); Form2 LOGIN = new Form2(remoteProxy, u); LOGIN.ShowDialog(); Close(); } else { //Show error message label3.Visible = true; } }