Understanding Async

I'm currently trying to implement the Google Directions API.
The library I'm using uses async methods to grab the data from the servers.

However, I'm having trouble understanding them.
I currently have a method calling the library implemented like this:

        private async void LoadDirections()
        {
            GoogleDirectionsResultSet result = await GoogleDirections.RouteBetweenWaypoints("KEY_HERE", WayPoint1, WayPoint2, MeasurementUnits.Metric, "en");
            if (result.Status.Equals("OK"))
            {
                this.Routes = result.Routes;
                foreach (Route route in this.Routes)
                {
                    Console.WriteLine(route.Summary); //Test code
                }
            }
        }

The method works fine when called in unit tests but whenever I call it from the UI thread it blocks the execution of that thread (and since I want to call it from OnResume in Android, that becomes a problem).
Shouldn't the async/await implementation prevent the blocking of the UI thread, or am I missing something here?

Posts

Sign In or Register to comment.