When using QueueBackgroundWorkItem, is there any difference in the below two ways of calling a method that performs async operations like api calls?
HostingEnvironment.QueueBackgroundWorkItem(async cancellationToken =>
{
var result = await LongRunningMethodAsync();
});
Or the following:
HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => LongRunningMethodAsync());
I'm aware of the detailed answers in Why use async with QueueBackgroundWorkItem? But they appear to focus on whether calling the Async vs Sync version of LongRunningMethod are better, and are not clear as to whether the above would make any difference.
I currently use the second method through-out my web application and can see that my async operations do in fact appear to run async.