I would like to handle long running operation in separate thread and return control back to GUI thread ASAP using async/await pattern as follows:
private
You can use Task.Run or Task.Factory.StartNew to execute Test() or some long running and/or blocking operation on another thread:
Task.Run
Task.Factory.StartNew
Test()
private async void Button_Click(object sender, RoutedEventArgs e) { await Task.Run(() => Test()); txtResult.Text = "Done!"; }