示例#1
0
        /// <summary>
        /// run tasks by parralel
        /// </summary>
        /// <param name="urls">request data</param>
        /// <returns>web crawler response</returns>
        public async Task <bool> GetReponseByUrls(List <string> urls)
        {
            try
            {
                //check if uri are valid
                this.commonHelper.CheckUrlArrayIsValid(ref urls);
                //check if uri allready exists on cache
                this.CheckIfUriExistsOnCache(ref urls);

                List <Task <WebCrawlerNode> > tasks = new List <Task <WebCrawlerNode> >();
                for (int i = 0; i < urls.Count; i++)
                {
                    tasks.Add(proxy.GetRestCallAsyncResponse(urls[i]));
                }
                var results = await Task.WhenAll(tasks);

                this.SetResultsOnCache(results.ToList());
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }