WebRequestExtensions


 public static class WebRequestExtensions
    {
        public static Task<WebResponse> GetReponseAsync(this WebRequest request)
        {
            return Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null);
        }
    }

webRequest.GetReponseAsync().ContinueWith(t =>
                {
                    if (t.Exception == null)
                    {
                        using (var sr = new StreamReader(t.Result.GetResponseStream()))
                        {
                            Coordinats result = ParseAsyncResultFromString2Xml(sr);
                            //if this true - then the coordinats are not accepted from google or the adress is not correct
                            if (!Coordinats.IsNotDefined(result))
                                _logger.LogInfo("Coordinats are empty some value was not implemented");
                            else
                            {
                                Coordinats = result;
                                _logger.LogInfo("Success!!! - Coordinats are ok");
                            }
                        }
                    }
                    else
                    {
                        _logger.LogInfo("Getting coordinats ==> Error!!!");
                        _logger.LogError(t.Exception);
                    }
                }).Wait();

שם של - callback
ParseAsyncResultFromString2Xml

Comments

Popular posts from this blog

c# Service Play Sound with NAudio example by Moshe

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem

JS/JQ simulate Enter event