i have button1_click method like this
private async void button1_Click(object sender, EventArgs e)
{
Task<string> st1 = Task.Run(() => ReadFromFile());
textBox1.AppendText("sdsadsa");
textBox1.Text = st1.Result;
}
i want to read from text file with ReadFromFile()
Note : ReadFromFile is marked with async because i want to use async and await in this method
to planning some Task methods
but my Ui is freezing after append text method calling in line 2 in my button1_click method
and wait the result and show it in text box.
i want to throw the ReadFromFile method in task and await it without ui freezing
i tried many things like replacing line 1 with this
Task<string> st1 = await Task.Factory.StartNew(() => ReadFromFile());
with this, ui dont freeze but it skips line 2 the append method , i dont know why this skiping?