I have made an application in WPF, in which in a window i have implemented Login method on click of login button. I want that the UI dont freezes when i click on button , as the login method uses WCF services and takes a plenty of 30 to 40 secs in completing transaction.
I am using this code..
new Thread(() =>{
Thread.CurrentThread.IsBackground = true;
if (this.LoginReq())
{
this.Hide();
new MenuScreen()
{
MainForm = this
}.Show();
}
}).Start();
but when in another thread i want to change the UI, it throws exception. I want a code through which i could call the login process in background and it does not freezes my UI, and i can do any process on the UI like changing the message of txtMessage on the form, or show progress bar.