Using async await still freezes GUI
<p>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:        </p>

<pre><code>private async void Button_Click(object sender, RoutedEventArgs e)
{
    await Test();
    txtResult.Text = "Done!";
}

private Task Test()
{
    Thread.Sleep(3000);
    return Task.FromResult(0);
}
</code></pre>

<p>The problem is, it freezes GUI anyway for 3 seconds (it becomes unresponsive until Done! is displayed after 3 seconds). What am I doing wrong?</p>

<p>EDIT:
I am trying to replace the following logic:</p>

<pre><code>private void Button_Click(object sender, RoutedEventArgs e)
{
    var thread = new Thread(() =&gt; Test(Callback));
    thread.Start();
}

private void Callback()
{
    Dispatcher.Invoke(() =&gt;
        txtResult.Text = "Done!");
}

private void Test(Action callback)
{
    Thread.Sleep(3000); //long running operation, not necessarily pause
    callback();
}
</code></pre>

<p>In actual project I have different long running logic than just Sleep, and it still freezes GUI, so replacing it with Task.Delay does not solve anything. Besides, I don't get why you should use yet another command for Sleep? How is this required by async/await design?</p>