/// <summary> /// Multithreading Login /// </summary> private void GoogleButton_Click() { GoogleButton.Invoke(new Action(() => GoogleButton.BackColor = Color.Transparent)); if (userChanger.GoogleLogin()) { GoogleButton.Invoke(new Action(() => GoogleButton.BackColor = Color.LightGreen)); CalendarsBox.Invoke(new Action(() => CalendarsBox.Enabled = true)); NewCalendarBox.Invoke(new Action(() => NewCalendarBox.Enabled = true)); } else { GoogleButton.Invoke(new Action(() => GoogleButton.BackColor = Color.OrangeRed)); } }
private void SetGoogleButtonEnabled(bool enabled) { MethodInvoker mi = new MethodInvoker(() => { GoogleButton.Enabled = enabled; }); if (GoogleButton.InvokeRequired) { GoogleButton.Invoke(mi); } else { mi.Invoke(); } }