Reputation: 621
I have a login page and I want the login button to disable while the SQL query is checking whether it's a valid account.
This is so that you can't press the login button twice or more times while it's already trying to do it's thing. Just like any decent software.
When I call
signinButton.IsEnabled = false
in my signinButton_Click method it doesn't disable it until after my SQL has returned...
If I call MessageBox.Show("called") it will display it instantly, as expected, but for some reason that's not the same with IsEnabled.
Do I really need to use a seperate thread for this? It seems overly complicated, all I want to do is disable the button instantly, and not after the SQL has finished.
Much appreciated
Upvotes: 1
Views: 73
Reputation: 1487
Consider using async versions of your database calls with the await
keyword. This allows your UI to be updated while query results are loaded.
Upvotes: 1