WPF blocking attempt asynchronously
I am learning about async / await keywords. I can't see what I am doing here syntactically here?
I have the following two methods:
private async Task<string> PopupAsync()
{
String result;
using (StreamReader reader = File.OpenText(@"C:\temp\JBM_SchedulingModule.xap"))
{
Console.WriteLine("Opened file.");
txtData.Text = "Opened file.";
result = await reader.ReadToEndAsync();
}
return result;
}
and
private async void Button_Click(object sender, RoutedEventArgs e)
{
txtData.Text = await PopupAsync();
}
The main UI thread freezes when I click the button and I don't want that. Trying to understand why and how to fix it.
Thank!
0
source to share