I have a dialog with some txb\'s and a button. When this button is clicked I want to change the button\'s Text, disable the button, start some Logic and then close the Window.>
when button is clicked:
button.Enabled = false;
button.Text = "new text";
Task.Factory.StartNew(() =>
{
// do your tasks here and close the window.
// type your code normally like calling methods. setting variables etc...
StaticVariable = ExampleUsingMethod();
});
if your variable needs to be assigned to UI later then you need dispatcher.for example if you want to change button inside the new thread.
Task.Factory.StartNew(() =>
{
Dispatcher.Invoke(() =>
{
button.Enabled = false;
button.Text = "new text";
}
StaticVariable = ExampleUsingMethod();
});