Async method signature error. Must return void, Task or Task <T>
I have an asynchronous method.
private static async Task InsertConnectionStatusIntoAzureDatabaseAsync(Device device)
{
...
}
I call this with
await InsertConnectionStatusIntoAzureDatabaseAsync(device).ConfigureAwait(false);
Visual studio won't build by saying that async method must return void, Task or Task<T>
It also blushes at the line InsertConnectionStatusIntoAzureDatabaseAsync(device).ConfigureAwait(false);
:
Task does not contain ConfigureAwait () definition
Headers are used at the top of the file
using System.Threading.Tasks;
using System.Threading;
The .net framework it targets is 4.6.1.
source to share
You almost certainly have another class in your project named Task
that conflicts with the .Net Framework version. You can check this by going to the type definition Task
and see where it goes. So either rename your version to something different (probably a better option), or use the full namespace:
private static async System.Threading.Tasks.Task InsertConnectionStatusIntoAzureDatabaseAsync()
{
//snip
}
source to share