How to use Form.AcceptButton properly when I want to use WaitCursor?
I decided to create login form like a boss and use Form.AcceptButton
property for the first time.
I have problem with locking controls when my Login function is working.
When I hit enter - form freezes.
When I click Login button manually - everything is fine. Cursor switches
to wait cursor, controls are disabled, everything is OK.
Here is my code (simplified):
private void btnLogin_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
// foreach loop that sets Enabled = false on all controls on form
LockControls();
// this function tries to login to SOAP web service, sometimes it
takes few seconds
Login();
this.Cursor = Cursors.Default;
// foreach loop that sets Enabled = true on all controls on form
UnlockControls();
}
Something is wrong with my code or idea?
No comments:
Post a Comment