Avatar of deleyd
deleyd
Flag for United States of America

asked on 

Async event handler Task.Run() vs. normal event handler Task.Run()?

What would be the difference between these two event handlers, one with async, the other without:
private async void ToolStripPlay_Click(object sender, EventArgs e)
{
    var task = Task.Run(() => this.Play()).ConfigureAwait(continueOnCapturedContext: false);
    await task;
}

Open in new window

private void ToolStripPlay_Click(object sender, EventArgs e)
{
    var task = Task.Run(() => this.Play()).ConfigureAwait(continueOnCapturedContext: false);
}

Open in new window

Is there any benefit to using async in this case?
.NET ProgrammingC#

Avatar of undefined
Last Comment
Dirk Strauss

8/22/2022 - Mon