GetAsync() public method

public GetAsync ( ) : Task
return Task
Example #1
0
        protected async Task Dsicover()
        {
            var navigation = new HtmlPageNavigator(_config.UrlFormat);

            int start = _config.Start;

            int end = _config.Start + _config.Length;

            var encoding = Encoding.GetEncoding(_config.Encoding);

            for (int i = start; i < end; i++)
            {
                if(_isCanceled)
                {
                    return;
                }

                navigation.NavigateTo(i);

                try
                {
                    string text = string.Empty;

                    using (var content = await navigation.GetAsync())
                    using (var sr = new StreamReader(content, encoding))
                    {
                        text = await sr.ReadToEndAsync();
                    }

                    Parse(text);
                }
                catch (Exception ex)
                {
                    continue;
                }               
            }
        }
Example #2
0
        protected async Task Dsicover()
        {
            var navigation = new HtmlPageNavigator(_config.UrlFormat);

            int start = _config.Start;

            int end = _config.Start + _config.Length;

            var encoding = Encoding.GetEncoding(_config.Encoding);

            for (int i = start; i < end; i++)
            {
                if (_isCanceled)
                {
                    return;
                }

                navigation.NavigateTo(i);

                try
                {
                    string text = string.Empty;

                    using (var content = await navigation.GetAsync())
                        using (var sr = new StreamReader(content, encoding))
                        {
                            text = await sr.ReadToEndAsync();
                        }

                    Parse(text);
                }
                catch (Exception ex)
                {
                    continue;
                }
            }
        }