chadly / Geocoding.net

C# GeoCoding / Address Validation API
MIT License
443 stars 155 forks source link

Tasks GeocodeAsync and reverse not marked as async #130

Closed AndreLuzHC closed 4 years ago

AndreLuzHC commented 4 years ago

Error message: "The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'."

Error line: IEnumerable addresses = await geocoder.GeocodeAsync("adress");

as the tasks are not marked as async I cannot use the await protocol to make it work. Alternatively I managed to make it work by removing the await and puting the .result at the end, but that just doesn't make much sense.

chadly commented 4 years ago

The method in question does indeed return a Task and works with async. I think the error message you were seeing was referring to your own method in which you were calling await geocoder.GeocodeAsync. You need to mark it as async in order to use the await keyword from within it.