The return type of an async method must be void, Task or Task<T>
Change the return type to Task<Dictionary<string, float>>
:
public async Task<Dictionary<string, float>> GetLikelihoodsAsync(List<string> inputs)
you can also replace your usage of ContinueWith
to use await
:
var response = await GetResponseAsync(requestData, client, uri);
var result = await ParseResponseAsync(response);
return result;
As stated in the error:
The return type of an async method must be
void
,Task
orTask<T>
In your case that would be Task<T>
, or specifically Task<Dictionary<string, float>>
. So, your method needs to be declared as this:
public async Task<Dictionary<string, float>> GetLikelihoodsAsync(List<string> inputs)
Note that you don't actually need to return a Task<T>
, you only need to return T
. You can read more about it here.