For example, the difference between this code
public Task<IList<NewsSentimentIndexes>> GetNewsSentimentIndexes(DateTime @from, DateTime to = new DateTime(), string grouping = "1h") { var result = _conf.BasePath .AppendPathSegment("news-sentiment-indexes") .SetQueryParams(new { from = from.ToString("s"), to = to.ToString("s"), grouping }); return result .GetStringAsync() .ContinueWith(Desereialize<IList<NewsSentimentIndexes>>); }
So what
public async Task<IList<NewsSentimentIndexes>> GetNewsSentimentIndexes(DateTime @from, DateTime to = new DateTime(), string grouping = "1h") { var result = _conf.BasePath .AppendPathSegment("news-sentiment-indexes") .SetQueryParams(new { from = from.ToString("s"), to = to.ToString("s"), grouping }); var newsStr = await result.GetStringAsync(); return JsonConvert.DeserializeObject<NewsSentimentIndexes>(newsStr); }
Which one is correct or faster? And just call this method need to wait or just complete the task?
c # asynchronous parallel-processing task-parallel-library task
Gleb patcia
source share