Internally used for passing state between route asynchronous calls.
        private void GeocodeAddress(string address, RoutingState state)
        {
            var request = new GeocodeRequest()
            {
                Culture = CultureInfo.CurrentUICulture.Name,
                Query = address,

                // Don't raise exceptions.
                ExecutionOptions = new UsingBingMaps.Bing.Geocode.ExecutionOptions()
                {
                    SuppressFaults = true
                },

                // Only accept results with high confidence.
                Options = new GeocodeOptions()
                {
                    Filters = new ObservableCollection<FilterBase>
                    {
                        new ConfidenceFilter()
                        {
                            MinimumConfidence = UsingBingMaps.Bing.Geocode.Confidence.High
                        }
                    }
                }
            };

            // Get credentials and only then place an async call on the geocode service.
            _credentialsProvider.GetCredentials(credentials =>
            {
                // Pass in credentials for web services call.
                // Replace with your own Credentials.
                request.Credentials = credentials;

                // Make asynchronous call to fetch the data.
                _geocodeClient.GeocodeAsync(request, state);
            });
        }
        public void CalculateAsync()
        {
            if (from_address == true)
            {
                // Geocode locations in parallel.
                var results = new GeocodeResult[2];

                // To location.
                var state1 = new RoutingState(results, 1, _to);
                GeocodeAddress(_to, state1);

                // From location.
                var state0 = new RoutingState(results, 0, _from);
                GeocodeAddress(_from, state0);
            }
        }